1
0
Fork 0

virtio: release virtio index when fail to device_register

commit e60ea67bb6 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>
pull/10/head
weiping zhang 2017-11-29 09:23:01 +08:00 committed by Greg Kroah-Hartman
parent 1f5d203906
commit c5a5c47c40
1 changed files with 2 additions and 0 deletions

View File

@ -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);