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]
Date:   Mon, 21 Aug 2023 13:43:51 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Bartosz Golaszewski <brgl@...ev.pl>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Kent Gibson <warthog618@...il.com>, linux-gpio@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH] gpiolib: notify user-space about line state changes
 triggered by kernel

On Fri, Aug 18, 2023 at 09:09:44PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>

Interestingly why you keep submitter and author different...

> We currently only emit CHANGED_CONFIG events when the user-space changes
> GPIO config. We won't be notified if changes come from in-kernel. Let's
> call the notifier chain whenever kernel users change direction or any of
> the active-low, debounce or consumer name settings. We don't notify the
> user-space about the persistence as the uAPI has no notion of it.

...

> -	if (!ret)
> +	if (!ret) {
>  		set_bit(FLAG_IS_OUT, &desc->flags);
> +		blocking_notifier_call_chain(&desc->gdev->notifier,
> +					     GPIO_V2_LINE_CHANGED_CONFIG,
> +					     desc);
> +	}
>  	trace_gpio_value(desc_to_gpio(desc), 0, val);
>  	trace_gpio_direction(desc_to_gpio(desc), 0, ret);
>  	return ret;

The if (!ret) makes me a bit slower to understand as usual pattern to test
for the errors first.

That said, perhaps

	if (ret)
		goto out_trace_event;

	set_bit(FLAG_IS_OUT, &desc->flags);
	blocking_notifier_call_chain(&desc->gdev->notifier,
				     GPIO_V2_LINE_CHANGED_CONFIG, desc);

out_trace_event:
	trace_gpio_value(desc_to_gpio(desc), 0, val);
	trace_gpio_direction(desc_to_gpio(desc), 0, ret);
	return ret;

...

> +	ret = gpiod_set_config(desc, config);
> +	if (!ret)
> +		blocking_notifier_call_chain(&desc->gdev->notifier,
> +					     GPIO_V2_LINE_CHANGED_CONFIG,
> +					     desc);
> +	return ret;

Ditto.

	ret = gpiod_set_config(desc, config);
	if (ret)
		return ret;

	blocking_notifier_call_chain(&desc->gdev->notifier,
				     GPIO_V2_LINE_CHANGED_CONFIG, desc);
	return 0;

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ