Patch "net: fec: avoid lock evasion when reading pps_enable" has been added to the 6.6-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

    net: fec: avoid lock evasion when reading pps_enable

to the 6.6-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:
     net-fec-avoid-lock-evasion-when-reading-pps_enable.patch
and it can be found in the queue-6.6 subdirectory.

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



commit 727ba58127d75725911ceff73b7edbb50ee4cea1
Author: Wei Fang <wei.fang@xxxxxxx>
Date:   Tue May 21 10:38:00 2024 +0800

    net: fec: avoid lock evasion when reading pps_enable
    
    [ Upstream commit 3b1c92f8e5371700fada307cc8fd2c51fa7bc8c1 ]
    
    The assignment of pps_enable is protected by tmreg_lock, but the read
    operation of pps_enable is not. So the Coverity tool reports a lock
    evasion warning which may cause data race to occur when running in a
    multithread environment. Although this issue is almost impossible to
    occur, we'd better fix it, at least it seems more logically reasonable,
    and it also prevents Coverity from continuing to issue warnings.
    
    Fixes: 278d24047891 ("net: fec: ptp: Enable PPS output based on ptp clock")
    Signed-off-by: Wei Fang <wei.fang@xxxxxxx>
    Link: https://lore.kernel.org/r/20240521023800.17102-1-wei.fang@xxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 181d9bfbee220..e32f6724f5681 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -104,14 +104,13 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable)
 	struct timespec64 ts;
 	u64 ns;
 
-	if (fep->pps_enable == enable)
-		return 0;
-
-	fep->pps_channel = DEFAULT_PPS_CHANNEL;
-	fep->reload_period = PPS_OUPUT_RELOAD_PERIOD;
-
 	spin_lock_irqsave(&fep->tmreg_lock, flags);
 
+	if (fep->pps_enable == enable) {
+		spin_unlock_irqrestore(&fep->tmreg_lock, flags);
+		return 0;
+	}
+
 	if (enable) {
 		/* clear capture or output compare interrupt status if have.
 		 */
@@ -532,6 +531,9 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
 	int ret = 0;
 
 	if (rq->type == PTP_CLK_REQ_PPS) {
+		fep->pps_channel = DEFAULT_PPS_CHANNEL;
+		fep->reload_period = PPS_OUPUT_RELOAD_PERIOD;
+
 		ret = fec_ptp_enable_pps(fep, on);
 
 		return ret;




[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