mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
pwm: sifive: Call pwm_sifive_update_clock() while mutex is held
[ Upstream commit45558b3abb
] As was documented in commit0f02f491b7
("pwm: sifive: Reduce time the controller lock is held") a caller of pwm_sifive_update_clock() must hold the mutex. So fix pwm_sifive_clock_notifier() to grab the lock. While this necessity was only documented later, the race exists since the driver was introduced. Fixes:9e37a53eb0
("pwm: sifive: Add a driver for SiFive SoC PWM") Reported-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Reviewed-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Link: https://lore.kernel.org/r/20221018061656.1428111-1-u.kleine-koenig@pengutronix.de 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>
This commit is contained in:
parent
37ea9a6c41
commit
eec59807a2
1 changed files with 4 additions and 1 deletions
|
@ -217,8 +217,11 @@ static int pwm_sifive_clock_notifier(struct notifier_block *nb,
|
||||||
struct pwm_sifive_ddata *ddata =
|
struct pwm_sifive_ddata *ddata =
|
||||||
container_of(nb, struct pwm_sifive_ddata, notifier);
|
container_of(nb, struct pwm_sifive_ddata, notifier);
|
||||||
|
|
||||||
if (event == POST_RATE_CHANGE)
|
if (event == POST_RATE_CHANGE) {
|
||||||
|
mutex_lock(&ddata->lock);
|
||||||
pwm_sifive_update_clock(ddata, ndata->new_rate);
|
pwm_sifive_update_clock(ddata, ndata->new_rate);
|
||||||
|
mutex_unlock(&ddata->lock);
|
||||||
|
}
|
||||||
|
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue