virtio: release virtio index when fail to device_register
index can be reused by other virtio device. Cc: stable@vger.kernel.org Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
23f1b8d938
commit
e60ea67bb6
|
@ -333,6 +333,8 @@ int register_virtio_device(struct virtio_device *dev)
|
||||||
/* device_register() causes the bus infrastructure to look for a
|
/* device_register() causes the bus infrastructure to look for a
|
||||||
* matching driver. */
|
* matching driver. */
|
||||||
err = device_register(&dev->dev);
|
err = device_register(&dev->dev);
|
||||||
|
if (err)
|
||||||
|
ida_simple_remove(&virtio_index_ida, dev->index);
|
||||||
out:
|
out:
|
||||||
if (err)
|
if (err)
|
||||||
virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
|
virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
|
||||||
|
|
Loading…
Reference in New Issue