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:
parent
1f5d203906
commit
c5a5c47c40
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user