Commit f1335ebd authored by Simon South's avatar Simon South Committed by Zheng Zengkai
Browse files

pwm: rockchip: Eliminate potential race condition when probing



stable inclusion
from stable-5.10.20
commit 58516ac4aac8890cfc8327f82bbaf3c00ae9cb89
bugzilla: 50608

--------------------------------

[ Upstream commit d21ba5d6 ]

Commit 48cf973c ("pwm: rockchip: Avoid glitches on already running
PWMs") introduced a potential race condition in rockchip_pwm_probe(): A
consumer could enable an inactive PWM, or disable a running one, between
rockchip_pwm_probe() registering the device via pwmchip_add() and checking
whether it is enabled (to determine whether it was started by a
bootloader). This could result in a device's PWM clock being either enabled
once more than necessary, potentially causing it to continue running when
no longer needed, or disabled once more than necessary, producing a warning
from the kernel.

Eliminate these possibilities by modifying rockchip_pwm_probe() so it
checks whether a device is enabled before registering it rather than after.

Fixes: 48cf973c ("pwm: rockchip: Avoid glitches on already running PWMs")
Reported-by: default avatarTrent Piepho <tpiepho@gmail.com>
Signed-off-by: default avatarSimon South <simon@simonsouth.net>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarChen Jun <chenjun102@huawei.com>
Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent e82c7900
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment