Skip to content

Commit 54921a8

Browse files
Sishuai Gongmchehab
authored andcommitted
media: vivid: fix the racy dev->radio_tx_rds_owner
There is a race over dev->radio_tx_rds_owner between the two functions mentioned below: Thread-1 Thread-2 vivid_fop_release() vivid_radio_rx_read() mutex_unlock(&dev->mutex) mutex_lock_interruptible(&dev->mutex) ... dev->radio_rx_rds_owner = file->private_data; ... if (file->private_data == dev->radio_rx_rds_owner) { dev->radio_tx_rds_last_block = 0; dev->radio_tx_rds_owner = NULL; } This race can be fixed by only releasing the lock after vivid_fop_release() finishes the checks. Signed-off-by: Sishuai Gong <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 607bcc4 commit 54921a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/media/test-drivers/vivid/vivid-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,6 @@ static int vivid_fop_release(struct file *file)
628628
v4l2_info(&dev->v4l2_dev, "reconnect\n");
629629
vivid_reconnect(dev);
630630
}
631-
mutex_unlock(&dev->mutex);
632631
if (file->private_data == dev->radio_rx_rds_owner) {
633632
dev->radio_rx_rds_last_block = 0;
634633
dev->radio_rx_rds_owner = NULL;
@@ -637,6 +636,7 @@ static int vivid_fop_release(struct file *file)
637636
dev->radio_tx_rds_last_block = 0;
638637
dev->radio_tx_rds_owner = NULL;
639638
}
639+
mutex_unlock(&dev->mutex);
640640
if (vdev->queue)
641641
return vb2_fop_release(file);
642642
return v4l2_fh_release(file);

0 commit comments

Comments
 (0)