mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Gui-Dong Han <hanguidong02@gmail.com>,
	linux-pm@vger.kernel.org, Danilo Krummrich <dakr@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Len Brown <lenb@kernel.org>, Pavel Machek <pavel@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Tony Lindgren <tony@atomide.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: Re: [PATCH v2] PM: sleep: wakeirq: harden dev_pm_clear_wake_irq() against races
Date: Tue, 3 Feb 2026 10:16:23 +0100	[thread overview]
Message-ID: <cf5945f4-83b5-4fee-8f37-bdc8048eacab@web.de> (raw)
In-Reply-To: <20260203031943.1924-1-hanguidong02@gmail.com>

…
> +++ b/drivers/base/power/wakeirq.c
> @@ -83,13 +83,16 @@ EXPORT_SYMBOL_GPL(dev_pm_set_wake_irq);
>   */
>  void dev_pm_clear_wake_irq(struct device *dev)
>  {
> -	struct wake_irq *wirq = dev->power.wakeirq;
> +	struct wake_irq *wirq;
>  	unsigned long flags;
>  
> -	if (!wirq)
> +	spin_lock_irqsave(&dev->power.lock, flags);
> +	wirq = dev->power.wakeirq;
> +	if (!wirq) {
> +		spin_unlock_irqrestore(&dev->power.lock, flags);
>  		return;
> +	}
>  
> -	spin_lock_irqsave(&dev->power.lock, flags);
>  	device_wakeup_detach_irq(dev);
>  	dev->power.wakeirq = NULL;
>  	spin_unlock_irqrestore(&dev->power.lock, flags);

Would it become feasible to apply a scoped_guard() call?
https://elixir.bootlin.com/linux/v6.19-rc5/source/include/linux/spinlock.h#L585

Regards,
Markus

  reply	other threads:[~2026-02-03  9:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03  3:19 Gui-Dong Han
2026-02-03  9:16 ` Markus Elfring [this message]
2026-02-03 20:26   ` Rafael J. Wysocki
2026-02-03 21:25 ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cf5945f4-83b5-4fee-8f37-bdc8048eacab@web.de \
    --to=markus.elfring@web.de \
    --cc=baijiaju1990@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hanguidong02@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®