lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aYRkQRqmJZ-CMEhU@google.com>
Date: Thu, 5 Feb 2026 09:34:57 +0000
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Linus Walleij <linusw@...nel.org>
Cc: Bartosz Golaszewski <brgl@...nel.org>, linux-gpio@...r.kernel.org,
	linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v2] gpio: Fix resource leaks on errors in
 gpiochip_add_data_with_key()

On Tue, Feb 03, 2026 at 10:35:14AM +0100, Linus Walleij wrote:
> On Tue, Feb 3, 2026 at 7:02 AM Tzung-Bi Shih <tzungbi@...nel.org> wrote:
> > Also reorder the instructions to make the error handling simpler.
> > Now gpiochip_add_data_with_key() roughly looks like:
> >
> >    >>> Some memory allocation.  Go to ERR ZONE 1 on errors.
> >    >>> device_initialize().
> >
> >    (gpiodev_release() takes over the responsibility for freeing the
> >     resources of `gdev->dev`.  The subsequent error handling paths
> >     shouldn't go through ERR ZONE 1 again which leads to double free.)
> 
> This doesn't need to be parenthesized, it should be pointed out
> so people can follow it, also:
> 
[...]
> > +       device_initialize(&gdev->dev);
> > +       gdev->dev.type = &gpio_dev_type;
> 
> 
> This is the point where, from this point on, gpiodev_release() will
> get called from the type.
> 
> This is worth a comment in the code don't you think?
> 
> Something like:
> 
> /*
>  * After this point any allocated resources will be free():d by
>  * gpiodev_release(), if you add new resources then make sure
>  * they get free():ed there.
>  */
> gdev->dev.type = &gpio_dev_type;
> 
> This helps developers to do the right thing.
> 
> With that added comment:
> Reviewed-by: Linus Walleij <linusw@...nel.org>

Thanks for your review.  Fix both of them in v3
https://lore.kernel.org/all/20260205092840.2574840-1-tzungbi@kernel.org/.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ