]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
pwm: lpc18xx-sct: Initialize driver data and hardware before pwmchip_add()
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 10 Nov 2021 08:49:48 +0000 (09:49 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:58:02 +0000 (11:58 +0200)
commitad54b0fd73dc1dd100db1059f6e3820e1b1cf8c8
tree4900bb1667cdc5c3c61b1f487c4fb509bba2461a
parent6c8aaae44345c7107a1fb90f937f7354e0b3b188
pwm: lpc18xx-sct: Initialize driver data and hardware before pwmchip_add()

BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit 0401f24cd238ae200a23a13925f98de3d2c883b8 ]

When a driver calls pwmchip_add() it has to be prepared to immediately
get its callbacks called. So move allocation of driver data and hardware
initialization before the call to pwmchip_add().

This fixes a potential NULL pointer exception and a race condition on
register writes.

Fixes: 841e6f90bb78 ("pwm: NXP LPC18xx PWM/SCT driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 6f4f778f2747c23a14bda72df6bf5a445b68fee2)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/pwm/pwm-lpc18xx-sct.c