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: <68f682cb2627_10e2100dd@dwillia2-mobl4.notmuch>
Date: Mon, 20 Oct 2025 11:43:23 -0700
From: <dan.j.williams@...el.com>
To: "Rafael J. Wysocki" <rafael@...nel.org>, Linux PM
	<linux-pm@...r.kernel.org>
CC: Jonathan Cameron <jonathan.cameron@...wei.com>, Takashi Iwai
	<tiwai@...e.de>, LKML <linux-kernel@...r.kernel.org>, Linux PCI
	<linux-pci@...r.kernel.org>, Alex Williamson <alex.williamson@...hat.com>,
	Bjorn Helgaas <helgaas@...nel.org>, Zhang Qilong <zhangqilong3@...wei.com>,
	Ulf Hansson <ulf.hansson@...aro.org>, Frank Li <Frank.Li@....com>, "Dhruva
 Gole" <d-gole@...com>, Dan Williams <dan.j.williams@...el.com>
Subject: Re: [PATCH v1] PM: runtime: Fix conditional guard definitions

Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> 
> Since pm_runtime_get_active() returns 0 on success, all of the
> DEFINE_GUARD_COND() macros in pm_runtime.h need the "_RET == 0"
> condition at the end of the argument list or they would not work
> correctly.
> 
> Fixes: 9a0abc39450a ("PM: runtime: Add auto-cleanup macros for "resume and get" operations")
> Reported-by: kernel test robot <lkp@...el.com>
> Link: https://lore.kernel.org/linux-pm/202510191529.BCyjKlLQ-lkp@intel.com/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> ---
>  include/linux/pm_runtime.h |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -629,13 +629,13 @@ DEFINE_GUARD(pm_runtime_active_auto, str
>   * device.
>   */
>  DEFINE_GUARD_COND(pm_runtime_active, _try,
> -		  pm_runtime_get_active(_T, RPM_TRANSPARENT))
> +		  pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
>  DEFINE_GUARD_COND(pm_runtime_active, _try_enabled,
> -		  pm_runtime_resume_and_get(_T))
> +		  pm_runtime_resume_and_get(_T), _RET == 0)
>  DEFINE_GUARD_COND(pm_runtime_active_auto, _try,
> -		  pm_runtime_get_active(_T, RPM_TRANSPARENT))
> +		  pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
>  DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled,
> -		  pm_runtime_resume_and_get(_T))
> +		  pm_runtime_resume_and_get(_T), _RET == 0)

I missed the detail that these are named "try" guards, but return
"-error" on failure. In all the existing cases of "try" vs "conditional"
acquire the polarity is different, e.g.:

	DEFINE_GUARD_COND(rwsem_read, _try, down_read_trylock(_T))
	DEFINE_GUARD_COND(rwsem_read, _intr, down_read_interruptible(_T), _RET == 0)

So, while this fix is correct, I wonder if a follow-on patch should
change the naming..., but I cannot think of sufficient replacement.

Reminder for me to be vigilant about this detail moving forward:

Reviewed-by: Dan Williams <dan.j.williams@...el.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ