Patch "media: imon: Fix race getting ictx->lock" 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

    media: imon: Fix race getting ictx->lock

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:
     media-imon-fix-race-getting-ictx-lock.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 f4e1c5b71055248d6f9b0653ed4ee31e1a6e4f57
Author: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
Date:   Mon May 6 21:10:27 2024 +0000

    media: imon: Fix race getting ictx->lock
    
    [ Upstream commit 24147897507cd3a7d63745d1518a638bf4132238 ]
    
    Lets fix a race between mutex_is_lock() and mutex_lock().
    
    <-mutex is not locked
    if (!mutex_is_locked(&ictx->lock)) {
            unlock = true; <- mutex is locked externaly
            mutex_lock(&ictx->lock);
    }
    
    Let's use mutex_trylock() that does mutex_is_lock() and mutex_lock()
    atomically.
    
    Fix the following cocci warning:
    drivers/media/rc/imon.c:1167:1-7: preceding lock on line 1153
    
    Fixes: 23ef710e1a6c ("[media] imon: add conditional locking in change_protocol")
    Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
    Signed-off-by: Sean Young <sean@xxxxxxxx>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 253a1d1a840a0..cd4995e74b977 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1153,10 +1153,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_proto)
 
 	memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet));
 
-	if (!mutex_is_locked(&ictx->lock)) {
-		unlock = true;
-		mutex_lock(&ictx->lock);
-	}
+	unlock = mutex_trylock(&ictx->lock);
 
 	retval = send_packet(ictx);
 	if (retval)




[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