Re: [PATCH] virtio: release virtio index when fail to device_register

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

 



On Wed, Nov 29, 2017 at 09:23:01AM +0800, weiping zhang wrote:
> index can be reused by other virtio device.
> 
> Signed-off-by: weiping zhang <zhangweiping@xxxxxxxxxxxxxxx>

Thanks!
I've queued this up, this is needed on stable as well.


> ---
>  drivers/virtio/virtio.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index 48230a5..bf7ff39 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -333,6 +333,8 @@ int register_virtio_device(struct virtio_device *dev)
>  	/* device_register() causes the bus infrastructure to look for a
>  	 * matching driver. */
>  	err = device_register(&dev->dev);
> +	if (err)
> +		ida_simple_remove(&virtio_index_ida, dev->index);
>  out:
>  	if (err)
>  		virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
> -- 
> 2.9.4



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]