Patch "media: mc: mark the media devnode as registered from the, start" has been added to the 4.19-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: mc: mark the media devnode as registered from the, start

to the 4.19-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-mc-mark-the-media-devnode-as-registered-from-t.patch
and it can be found in the queue-4.19 subdirectory.

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



commit 81639b57df6e5e30f21227a45ffec539dc9e359a
Author: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
Date:   Fri Feb 23 09:46:19 2024 +0100

    media: mc: mark the media devnode as registered from the, start
    
    [ Upstream commit 4bc60736154bc9e0e39d3b88918f5d3762ebe5e0 ]
    
    First the media device node was created, and if successful it was
    marked as 'registered'. This leaves a small race condition where
    an application can open the device node and get an error back
    because the 'registered' flag was not yet set.
    
    Change the order: first set the 'registered' flag, then actually
    register the media device node. If that fails, then clear the flag.
    
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
    Acked-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
    Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
    Fixes: cf4b9211b568 ("[media] media: Media device node support")
    Cc: stable@xxxxxxxxxxxxxxx
    Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
index 6b87a721dc499..b4a62b3172e3d 100644
--- a/drivers/media/media-devnode.c
+++ b/drivers/media/media-devnode.c
@@ -253,15 +253,14 @@ int __must_check media_devnode_register(struct media_device *mdev,
 	devnode->cdev.owner = owner;
 
 	/* Part 3: Add the media and char device */
+	set_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
 	ret = cdev_device_add(&devnode->cdev, &devnode->dev);
 	if (ret < 0) {
+		clear_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
 		pr_err("%s: cdev_device_add failed\n", __func__);
 		goto cdev_add_error;
 	}
 
-	/* Part 4: Activate this minor. The char device can now be used. */
-	set_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
-
 	return 0;
 
 cdev_add_error:




[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