Re: [PATCH v1] driver core: Release all resources during unbind before updating device links

From: Saravana Kannan
Date: Wed Oct 18 2023 - 18:26:40 EST


On Wed, Oct 18, 2023 at 3:40 AM Uwe Kleine-König
<u.kleine-koenig@xxxxxxxxxxxxxx> wrote:
>
> On Tue, Oct 17, 2023 at 06:38:50PM -0700, Saravana Kannan wrote:
> > This commit fixes a bug in commit 9ed9895370ae ("driver core: Functional
> > dependencies tracking support") where the device link status was
> > incorrectly updated in the driver unbind path before all the device's
> > resources were released.
> >
> > Fixes: 9ed9895370ae ("driver core: Functional dependencies tracking support")
> > Reported-by: "Uwe Kleine-König" <u.kleine-koenig@xxxxxxxxxxxxxx>
> > Closes: https://lore.kernel.org/all/20231014161721.f4iqyroddkcyoefo@xxxxxxxxxxxxxx/
> > Signed-off-by: Saravana Kannan <saravanak@xxxxxxxxxx>
> > Cc: Thierry Reding <thierry.reding@xxxxxxxxx>
> > Cc: Yang Yingliang <yangyingliang@xxxxxxxxxx>
> > Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> > Cc: Mark Brown <broonie@xxxxxxxxxx>
> > Cc: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
> > Cc: James Clark <james.clark@xxxxxxx>
> > ---
> > drivers/base/dd.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> > index a528cec24264..0c3725c3eefa 100644
> > --- a/drivers/base/dd.c
> > +++ b/drivers/base/dd.c
> > @@ -1274,8 +1274,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
> > if (dev->bus && dev->bus->dma_cleanup)
> > dev->bus->dma_cleanup(dev);
> >
> > - device_links_driver_cleanup(dev);
> > device_unbind_cleanup(dev);
> > + device_links_driver_cleanup(dev);
>
> Tested-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
>
> This indeed fixes the crash I experinced before.

Thanks for the Tested-by!

-Saravana