Re: [PATCH v4 10/26] media: mc: Clear minor number reservation at unregistration time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/06/2024 12:05, Sakari Ailus wrote:
> 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.

Have you tested this?

I'm not certain whether this won't cause kobject errors. If an app has the
media device open when the device is unbound, then the old device node still
is around until the application closes the fh. I'm not sure if you can create
a new device node with the same minor while an old device node with the same
minor is still around.

V4L2 and CEC definitely both keep the old minor until the last user has gone.

Regards,

	Hans

> 
> 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 38c472498f9e..f7ecabe469a4 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);
> @@ -268,6 +261,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);
>  }
>  
>  /*





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux