]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
pwm: img: Fix null pointer access in probe
authorHauke Mehrtens <hauke@hauke-m.de>
Thu, 20 Aug 2020 17:14:25 +0000 (19:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Oct 2020 09:38:21 +0000 (10:38 +0100)
commitfef79803054786306d742fa6b9524d853072120a
treed300caab3918b1579c0746a486d247ab4787b538
parentdf6e89d6371b4331567a0e8aae87684eaa162611
pwm: img: Fix null pointer access in probe

[ Upstream commit b39c0615d0667b3a6f2f5c4bf99ffadf3b518bb1 ]

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>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pwm/pwm-img.c