]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Apr 2022 12:14:51 +0000 (14:14 +0200)
commit0a8400ba5752efc008e718c7c8db8be092fe23b3
tree26203fc475df3a8400f25b518dda14dc0924684d
parent685b6d16bf89595310b5d61394c9b97cc9505c7c
pwm: lpc18xx-sct: Initialize driver data and hardware before pwmchip_add()

[ 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>
drivers/pwm/pwm-lpc18xx-sct.c