Clear the media device's minor number reservation at unregister time as there's no need to keep it reserved for longer. This makes it possible to reserve the same minor right after unregistration. Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx> --- drivers/media/mc/mc-devnode.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c index dbf546853ca9..2538371a90af 100644 --- a/drivers/media/mc/mc-devnode.c +++ b/drivers/media/mc/mc-devnode.c @@ -49,13 +49,6 @@ static void media_devnode_release(struct device *cd) { struct media_devnode *devnode = to_media_devnode(cd); - mutex_lock(&media_devnode_lock); - - /* Mark device node number as free */ - clear_bit(devnode->minor, media_devnode_nums); - - mutex_unlock(&media_devnode_lock); - /* Release media_devnode and perform other cleanups as needed. */ if (devnode->release) devnode->release(devnode); @@ -270,6 +263,10 @@ void media_devnode_unregister(struct media_devnode *devnode) cdev_del(&devnode->cdev); device_unregister(&devnode->dev); + + mutex_lock(&media_devnode_lock); + clear_bit(devnode->minor, media_devnode_nums); + mutex_unlock(&media_devnode_lock); } /* -- 2.39.2