Re: [PATCH] mfd: intel-lpss: fix iDMA device leak on probe failure
From: Guangshuo Li
Date: Thu Sep 24 2026 - 08:01:52 EST
Thanks Andy and Mika.
On Tue, 22 Sept 2026 at 20:33, Mika Westerberg
<mika.westerberg@xxxxxxxxxxxxxxx> wrote:
>
> On Tue, Sep 22, 2026 at 03:29:24PM +0300, Andy Shevchenko wrote:
> > On Tue, Sep 22, 2026 at 03:59:32PM +0800, Guangshuo Li wrote:
> > > On Mon, 21 Sept 2026 at 19:05, Mika Westerberg
> > > <mika.westerberg@xxxxxxxxxxxxxxx> wrote:
> > > > On Mon, Sep 21, 2026 at 06:40:58PM +0800, Guangshuo Li wrote:
> >
> > > > I think this could use devm_mfd_add_devices() instead.
> > > >
> > > > > The issue was identified by a static analysis tool I developed and
> > > > > confirmed by manual review.
> >
> > > Do you mean converting both MFD registrations to devm_mfd_add_devices()
> > > and dropping the explicit mfd_remove_devices() from the remove path, like
> > > this?
> >
> > Won't work properly. The rule of thumb, it should be no 'goto' after devm_*() call.
>
> hmm, isn't the unwind done in driver core and has nothing to do with goto?
> Maybe things have changed since I last time looked? ;-)
devm_mfd_add_devices() would remove the children when the parent
device's devres is released after probe returns an error. However, the
current error path tears down the debugfs, LTR, clock, and IDA state
before returning, while intel_lpss_remove() removes the MFD children
before those resources.
Given that ordering, would keeping mfd_add_devices() and adding
mfd_remove_devices() at err_remove_ltr, as in the original patch, be
preferable here?
Thanks,
Guangshuo