Commit 893fab0c authored by weiping zhang's avatar weiping zhang Committed by Greg Kroah-Hartman

virtio: release virtio index when fail to device_register

commit e60ea67b upstream.

index can be reused by other virtio device.
Signed-off-by: default avatarweiping zhang <>
Reviewed-by: default avatarCornelia Huck <>
Signed-off-by: default avatarMichael S. Tsirkin <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 4b4e6f67
......@@ -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);
if (err)
add_status(dev, VIRTIO_CONFIG_S_FAILED);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment