* [PATCH v2] pwm: img: Fix null pointer access in probe
@ 2020-08-20 17:14 Hauke Mehrtens
2020-09-23 12:10 ` Thierry Reding
0 siblings, 1 reply; 2+ messages in thread
From: Hauke Mehrtens @ 2020-08-20 17:14 UTC (permalink / raw)
To: thierry.reding, u.kleine-koenig, lee.jones
Cc: ed.blake, linux-pwm, wigyori, Hauke Mehrtens
dev_get_drvdata() is called in img_pwm_runtime_resume() before the
driver data is set.
When pm_runtime_enabled() returns false in img_pwm_probe() it calls
img_pwm_runtime_resume() which results in a null pointer access.
This patch fixes the problem by setting the driver data earlier in the
img_pwm_probe() function.
This crash was seen when booting the Imagination Technologies Creator
Ci40 (Marduk) with kernel 5.4 in OpenWrt.
Fixes: e690ae526216 ("pwm: img: Add runtime PM")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
drivers/pwm/pwm-img.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
index 599a0f66a384..a34d95ed70b2 100644
--- a/drivers/pwm/pwm-img.c
+++ b/drivers/pwm/pwm-img.c
@@ -277,6 +277,8 @@ static int img_pwm_probe(struct platform_device *pdev)
return PTR_ERR(pwm->pwm_clk);
}
+ platform_set_drvdata(pdev, pwm);
+
pm_runtime_set_autosuspend_delay(&pdev->dev, IMG_PWM_PM_TIMEOUT);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_enable(&pdev->dev);
@@ -313,7 +315,6 @@ static int img_pwm_probe(struct platform_device *pdev)
goto err_suspend;
}
- platform_set_drvdata(pdev, pwm);
return 0;
err_suspend:
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] pwm: img: Fix null pointer access in probe
2020-08-20 17:14 [PATCH v2] pwm: img: Fix null pointer access in probe Hauke Mehrtens
@ 2020-09-23 12:10 ` Thierry Reding
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2020-09-23 12:10 UTC (permalink / raw)
To: Hauke Mehrtens; +Cc: u.kleine-koenig, lee.jones, ed.blake, linux-pwm, wigyori
[-- Attachment #1: Type: text/plain, Size: 803 bytes --]
On Thu, Aug 20, 2020 at 07:14:25PM +0200, Hauke Mehrtens wrote:
> dev_get_drvdata() is called in img_pwm_runtime_resume() before the
> driver data is set.
> When pm_runtime_enabled() returns false in img_pwm_probe() it calls
> img_pwm_runtime_resume() which results in a null pointer access.
>
> This patch fixes the problem by setting the driver data earlier in the
> img_pwm_probe() function.
>
> This crash was seen when booting the Imagination Technologies Creator
> Ci40 (Marduk) with kernel 5.4 in OpenWrt.
>
> Fixes: e690ae526216 ("pwm: img: Add runtime PM")
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
> drivers/pwm/pwm-img.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Applied, thanks.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-23 12:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-20 17:14 [PATCH v2] pwm: img: Fix null pointer access in probe Hauke Mehrtens
2020-09-23 12:10 ` Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox