Patch "pwm: sifive: Call pwm_sifive_update_clock() while mutex is held" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    pwm: sifive: Call pwm_sifive_update_clock() while mutex is held

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pwm-sifive-call-pwm_sifive_update_clock-while-mutex-.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f0b1e341a5665c5f97c94f4f07a1fc6fcb54d3e1
Author: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
Date:   Fri Dec 2 19:35:05 2022 +0100

    pwm: sifive: Call pwm_sifive_update_clock() while mutex is held
    
    [ Upstream commit 45558b3abb87eeb2cedb8a59cb2699c120b5102a ]
    
    As was documented in commit 0f02f491b786 ("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: 9e37a53eb051 ("pwm: sifive: Add a driver for SiFive SoC PWM")
    Reported-by: Emil Renner Berthing <emil.renner.berthing@xxxxxxxxxxxxx>
    Reviewed-by: Emil Renner Berthing <emil.renner.berthing@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221018061656.1428111-1-u.kleine-koenig@xxxxxxxxxxxxxx
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
    Signed-off-by: Thierry Reding <thierry.reding@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
index 9cc0612f0849..12e9e23272ab 100644
--- a/drivers/pwm/pwm-sifive.c
+++ b/drivers/pwm/pwm-sifive.c
@@ -217,8 +217,11 @@ static int pwm_sifive_clock_notifier(struct notifier_block *nb,
 	struct pwm_sifive_ddata *ddata =
 		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);
+		mutex_unlock(&ddata->lock);
+	}
 
 	return NOTIFY_OK;
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux