virtio: release virtio index when fail to device_register
commit e60ea67bb60459b95a50a156296041a13e0e380e upstream. index can be reused by other virtio device. Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4b4e6f6758
commit
893fab0c33
@@ -323,6 +323,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)
|
||||
add_status(dev, VIRTIO_CONFIG_S_FAILED);
|
||||
|
||||
Reference in New Issue
Block a user