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: <Z7dKfwOrAuhuZvQt@black.fi.intel.com>
Date: Thu, 20 Feb 2025 17:30:07 +0200
From: Raag Jadav <raag.jadav@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Zijun Hu <quic_zijuhu@...cinc.com>,
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
	linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Danilo Krummrich <dakr@...nel.org>,
	Linus Walleij <linus.walleij@...aro.org>,
	Bartosz Golaszewski <brgl@...ev.pl>
Subject: Re: [PATCH v1 3/4] devres: Add devm_remove_action_optional() helper

On Thu, Feb 20, 2025 at 03:44:59PM +0200, Andy Shevchenko wrote:
> Add a new helper to remove an action that was added via devm_add_action()
> family of calls, but not warn in the cases where action wasn't found since
> it is optional and wasn't even added.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
>  include/linux/device/devres.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
> index ae696d10faff..4daebbf7f227 100644
> --- a/include/linux/device/devres.h
> +++ b/include/linux/device/devres.h
> @@ -145,6 +145,19 @@ void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
>  	WARN_ON(devm_remove_action_nowarn(dev, action, data));
>  }
>  
> +/* Same as devm_remove_action(), but doesn't WARN() if action wasn't added before */
> +static inline
> +void devm_remove_action_optional(struct device *dev, void (*action)(void *), void *data)
> +{
> +	int ret;
> +
> +	ret = devm_remove_action_nowarn(dev, action, data);
> +	if (ret == -ENOENT)
> +		return;
> +
> +	WARN_ON(ret);
> +}

Trying to wrap my head around this one, can't the user simply do

	if (devm_is_action_added())
		devm_remove_action/_nowarn();

Raag

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ