media: Clear devnode->media_dev holding media_devnode_lock
authorShuah Khan <shuah@kernel.org>
Tue, 2 Apr 2019 00:43:18 +0000 (20:43 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 22 Apr 2019 15:24:33 +0000 (11:24 -0400)
Fix media_devnode_unregister() to clear devnode->media_dev while holding
media_devnode_lock. media_devnode_register()'s cdev_add_error handling
does this correctly.

Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/media-devnode.c

index 61dc05fcc55c5889334ca4076a5df98b83a0283e..d5aa30eeff4ac56252136f967b1cd7f955c9a65e 100644 (file)
@@ -291,8 +291,9 @@ void media_devnode_unregister(struct media_devnode *devnode)
        mutex_lock(&media_devnode_lock);
        /* Delete the cdev on this minor as well */
        cdev_device_del(&devnode->cdev, &devnode->dev);
-       mutex_unlock(&media_devnode_lock);
        devnode->media_dev = NULL;
+       mutex_unlock(&media_devnode_lock);
+
        put_device(&devnode->dev);
 }