All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Kent Gibson <warthog618@gmail.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH] gpiolib: tie module references to GPIO devices, not requested descs
Date: Mon, 21 Aug 2023 12:43:21 +0300	[thread overview]
Message-ID: <ZOMxue7lvHFWMCCb@smile.fi.intel.com> (raw)
In-Reply-To: <20230818190108.22031-1-brgl@bgdev.pl>

On Fri, Aug 18, 2023 at 09:01:08PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.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



  reply	other threads:[~2023-08-21  9:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 19:01 [PATCH] gpiolib: tie module references to GPIO devices, not requested descs Bartosz Golaszewski
2023-08-21  9:43 ` Andy Shevchenko [this message]
2023-08-21 10:00   ` Bartosz Golaszewski
2023-08-24 12:49     ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOMxue7lvHFWMCCb@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.