[PATCH 3.16 240/245] [media] media-devnode: add missing mutex lock in error handler

From: Ben Hutchings
Date: Thu Apr 23 2020 - 19:08:30 EST


3.16.83-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Max Kellermann <max@xxxxxxxxxxx>

commit 88336e174645948da269e1812f138f727cd2896b upstream.

We should protect the device unregister patch too, at the error
condition.

Signed-off-by: Max Kellermann <max@xxxxxxxxxxx>
Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxx>
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
drivers/media/media-devnode.c | 3 +++
1 file changed, 3 insertions(+)

--- a/drivers/media/media-devnode.c
+++ b/drivers/media/media-devnode.c
@@ -282,8 +282,11 @@ int __must_check media_devnode_register(
return 0;

error:
+ mutex_lock(&media_devnode_lock);
cdev_del(&mdev->cdev);
clear_bit(mdev->minor, media_devnode_nums);
+ mutex_unlock(&media_devnode_lock);
+
return ret;
}