Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] PM / wakeup: Skip wakeup_source_sysfs_remove if device is not added
@ 2020-03-23  5:08 Neeraj Upadhyay
  2020-03-25 10:37 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Neeraj Upadhyay @ 2020-03-23  5:08 UTC (permalink / raw)
  To: rjw, pavel, len.brown, gregkh, swboyd
  Cc: linux-pm, linux-kernel, irgeorgiev, linux-arm-msm, Neeraj Upadhyay

Skip wakeup_source_sysfs_remove(), to fix null pinter access of
ws->dev, if wakeup source is unregistered before wakeup class
is registered from device_add().

Fixes: 2ca3d1ecb8c4 ("PM / wakeup: Register wakeup class kobj after device is added")
Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
---
 drivers/base/power/wakeup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index 27f3e60..f8f8c0a 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -241,7 +241,8 @@ void wakeup_source_unregister(struct wakeup_source *ws)
 {
 	if (ws) {
 		wakeup_source_remove(ws);
-		wakeup_source_sysfs_remove(ws);
+		if (ws->dev)
+			wakeup_source_sysfs_remove(ws);
 		wakeup_source_destroy(ws);
 	}
 }
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] PM / wakeup: Skip wakeup_source_sysfs_remove if device is not added
  2020-03-23  5:08 [PATCH] PM / wakeup: Skip wakeup_source_sysfs_remove if device is not added Neeraj Upadhyay
@ 2020-03-25 10:37 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2020-03-25 10:37 UTC (permalink / raw)
  To: Neeraj Upadhyay
  Cc: pavel, len.brown, gregkh, swboyd, linux-pm, linux-kernel,
	irgeorgiev, linux-arm-msm

On Monday, March 23, 2020 6:08:51 AM CET Neeraj Upadhyay wrote:
> Skip wakeup_source_sysfs_remove(), to fix null pinter access of
> ws->dev, if wakeup source is unregistered before wakeup class
> is registered from device_add().
> 
> Fixes: 2ca3d1ecb8c4 ("PM / wakeup: Register wakeup class kobj after device is added")
> Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
> ---
>  drivers/base/power/wakeup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> index 27f3e60..f8f8c0a 100644
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -241,7 +241,8 @@ void wakeup_source_unregister(struct wakeup_source *ws)
>  {
>  	if (ws) {
>  		wakeup_source_remove(ws);
> -		wakeup_source_sysfs_remove(ws);
> +		if (ws->dev)
> +			wakeup_source_sysfs_remove(ws);
>  		wakeup_source_destroy(ws);
>  	}
>  }
> 

Applied (with some minor changes) as 5.7 material, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23  5:08 [PATCH] PM / wakeup: Skip wakeup_source_sysfs_remove if device is not added Neeraj Upadhyay
2020-03-25 10:37 ` Rafael J. Wysocki

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git