From: Shuah Khan Date: Tue, 2 Apr 2019 00:43:18 +0000 (-0400) Subject: media: Clear devnode->media_dev holding media_devnode_lock X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=10cb050459852fd954a5b38c019d2313f3bfb3e2;p=openwrt%2Fstaging%2Fblogic.git media: Clear devnode->media_dev holding media_devnode_lock 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 Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c index 61dc05fcc55c..d5aa30eeff4a 100644 --- a/drivers/media/media-devnode.c +++ b/drivers/media/media-devnode.c @@ -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); }