[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZOMxue7lvHFWMCCb@smile.fi.intel.com>
Date: Mon, 21 Aug 2023 12:43:21 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Kent Gibson <warthog618@...il.com>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH] gpiolib: tie module references to GPIO devices, not
requested descs
On Fri, Aug 18, 2023 at 09:01:08PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
>
> After a deeper look at commit 3386fb86ecde ("gpiolib: fix reference
> leaks when removing GPIO chips still in use") I'm now convinced that
> gpiolib gets module reference counting wrong.
>
> As we only take the reference to the owner module when a descriptor is
> requested and put it when it's freed, we can easily trigger a crash by
> removing a module which registered a driver bound to a GPIO chip which
> is unused as nothing prevents us from doing so.
>
> For correct behavior, we should take the reference to the module when
> we're creating a GPIO device and only put it when that device is
> released as it's at this point that we can safely remove the module's
> code from memory.
Two cases to consider:
1) legacy gpio_*() APIs, do they suppose to create a GPIO device?
2) IRQ request without GPIO being requested, is it the case?
Seems to me that the 1) is the case, while 2) is not.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists