From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
linus.walleij@linaro.org, linux-gpio@vger.kernel.org
Subject: Re: [PATCH] gpio: gpiolib: fix refcount imbalance in gpiochip_setup_dev()
Date: Fri, 6 Dec 2024 17:40:09 +0200 [thread overview]
Message-ID: <Z1Ma2WvvnQqzcKVh@smile.fi.intel.com> (raw)
In-Reply-To: <1cbec5a7-6c83-4abe-8532-041dbf891e16@pf.is.s.u-tokyo.ac.jp>
On Fri, Dec 06, 2024 at 05:53:25PM +0900, Joe Hattori wrote:
> Thank you for the review. And yes, I should have paid more attention to the
> code, sorry. I have reflected the reviewed points in the V2 patch, so please
> take a look at it.
I can't look at something I haven't received.
> On 12/5/24 22:20, Andy Shevchenko wrote:
> > On Wed, Dec 04, 2024 at 09:21:52PM +0900, Joe Hattori wrote:
> >> In gpiochip_setup_dev(), the refcount incremented in device_initialize()
> >> is not decremented in the error path. Fix it by calling put_device().
> >
> > First of all, we have gpio_put_device().
>
> Fixed in the V2 patch.
>
> > Second, what the problem do you have in practice? Can you show any
> backtrace?
> > Third, how had this change been tested?
>
> I am building a static analysis tool, and it reported this reference leak. I
> overlooked that it still reported the same error after this patch, and it is
> fixed in the V2 patch. If a backtrace is needed, I will try.
You missed the guidelines / rules about static analysis tools:
Documentation/process/researcher-guidelines.rst.
> > Looking at the current code I noticed the following:
> > 1) gpiochip_add_data_with_key() has already that call;
>
> Thank you for pointing out, the call has been removed in the V2 patch.
> > 2) gpiochip_setup_devs() misses that call.
>
> I was not sure if the gpiochip_setup_devs() should have an error path to
> remove all the registered GPIO devices when a single registration fails,
I don't think so. But that failed device should be put. It's the only issue
I see with the current code. If I'm wrong, prove it and elaborate in the commit
message (backtraces will be very helpful).
> thus it is not addressed in the V2 patch. If such a cleanup path is needed,
> please let me know.
>
> > This effectively means that you inroduce a regression while fixing a bug.
> >
> > The GPIO device initialisation is non-trivial, please pay more attention
> to the
> > code.
> >
> > Bart, can this be removed or reverted before it poisons stable?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-12-06 15:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 12:21 [PATCH] gpio: gpiolib: fix refcount imbalance in gpiochip_setup_dev() Joe Hattori
2024-12-04 17:09 ` Linus Walleij
2024-12-05 12:09 ` Bartosz Golaszewski
2024-12-05 13:20 ` Andy Shevchenko
2024-12-05 13:23 ` Andy Shevchenko
2024-12-05 13:30 ` Bartosz Golaszewski
2024-12-06 8:53 ` Joe Hattori
2024-12-06 15:40 ` Andy Shevchenko [this message]
2024-12-17 14:50 ` Dan Carpenter
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=Z1Ma2WvvnQqzcKVh@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=brgl@bgdev.pl \
--cc=joe@pf.is.s.u-tokyo.ac.jp \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox