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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MfzRVy85NR_eSQc3ZX_OmgCRUKuBdd6TqCu=Adwh9drrA@mail.gmail.com>
Date: Thu, 3 Apr 2025 08:58:09 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, linux-gpio@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Linus Walleij <linus.walleij@...aro.org>, 
	Florian Fainelli <florian.fainelli@...adcom.com>, Mark Brown <broonie@...nel.org>
Subject: Re: [PATCH v1 1/1] gpiolib: Make gpiod_put() error pointer aware

On Wed, Apr 2, 2025 at 5:20 PM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> When non-optional GPIO is requested and failed, the variable that holds
> the (invalid) descriptor can contain an error pointer. However, gpiod_put()
> ignores that fact and tries to cleanup never requested descriptor.
> Make sure gpiod_put() ignores that as well.
>
> While at it, do the same for the gpiod_put_array().
>
> Note, it arguable needs to be present in the stubs as those are usually
> called when CONFIG_GPIOLIB=n and GPIOs are requested using gpiod_get_optional()
> or similar APIs.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---

I'm not a fan of this. Silently ignoring NULL makes sense in the
context of _optional() calls where we want to do nothing on GPIOs that
aren't there. But this encourages people to get sloppy and just ignore
error pointers returned from gpiod_get()? Also: all other calls error
out on IS_ERR(desc) so why would we make it an exception? If anything,
the broadcom SPI driver this is about should store the return value of
gpiod_get() in a local variable, check it and then assign NULL to the
actual descriptor stored in the driver data.

We return errors for a reason, I don't like the idea of just ignoring
them in gpiod_put().

Bartosz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ