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: <Z73DWoscARsC06gS@smile.fi.intel.com>
Date: Tue, 25 Feb 2025 15:19:22 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Linus Walleij <linus.walleij@...aro.org>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH 2/3] gpiolib: use a more explicit retval logic in
 gpiochip_get_direction()

On Tue, Feb 25, 2025 at 12:56:24PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> 
> We have existing macros for direction settings so we don't need to rely
> on the magic value of 1 in the retval check. Use readable logic that
> explicitly says we expect INPUT, OUTPUT or a negative errno and nothing
> else in gpiochip_get_direction().

...

>  	ret = gc->get_direction(gc, offset);
> -	if (ret > 1)
> +	if (!(ret == GPIO_LINE_DIRECTION_OUT ||
> +	      ret == GPIO_LINE_DIRECTION_IN || ret < 0))
>  		ret = -EBADE;

Wouldn't be better to write it as

	if (ret < 0)
		return ret;

	if (ret != GPIO_LINE_DIRECTION_OUT && ret != GPIO_LINE_DIRECTION_IN)
		ret = -EBADE;

	return ret;


Otherwise LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
after addressing the above.

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ