From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Hauke Mehrtens <hauke@hauke-m.de>
Cc: thierry.reding@gmail.com, lee.jones@linaro.org,
ed.blake@sondrel.com, linux-pwm@vger.kernel.org, wigyori@uid0.hu
Subject: Re: [PATCH] pwm: img: Fix null pointer access in probe
Date: Thu, 20 Aug 2020 15:02:39 +0200 [thread overview]
Message-ID: <20200820130239.2rawmesibu535ohl@pengutronix.de> (raw)
In-Reply-To: <20200815163115.11376-1-hauke@hauke-m.de>
[-- Attachment #1: Type: text/plain, Size: 1846 bytes --]
On Sat, Aug 15, 2020 at 06:31:15PM +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.
Is this a theoretical issue, or did you see this crash on a machine?
> This patch fixes the problem by setting the driver data earlier in the
> img_pwm_probe() function.
>
> Fixes: e690ae526216 ("pwm: img: Add runtime PM")
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---
> drivers/pwm/pwm-img.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> index 599a0f66a384..11831e885e1b 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:
> @@ -322,6 +323,7 @@ static int img_pwm_probe(struct platform_device *pdev)
> err_pm_disable:
> pm_runtime_disable(&pdev->dev);
> pm_runtime_dont_use_autosuspend(&pdev->dev);
> + platform_set_drvdata(pdev, NULL);
The driver core takes care about removing drvdata, so this hunk isn't
necessary.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-08-20 13:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-15 16:31 [PATCH] pwm: img: Fix null pointer access in probe Hauke Mehrtens
2020-08-19 10:39 ` Lee Jones
2020-08-20 13:02 ` Uwe Kleine-König [this message]
2020-08-20 16:16 ` Hauke Mehrtens
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=20200820130239.2rawmesibu535ohl@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=ed.blake@sondrel.com \
--cc=hauke@hauke-m.de \
--cc=lee.jones@linaro.org \
--cc=linux-pwm@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=wigyori@uid0.hu \
/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