Skip to content

Commit e60ea67

Browse files
dubliomstsirkin
authored andcommitted
virtio: release virtio index when fail to device_register
index can be reused by other virtio device. Cc: [email protected] Signed-off-by: weiping zhang <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 23f1b8d commit e60ea67

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/virtio/virtio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ int register_virtio_device(struct virtio_device *dev)
333333
/* device_register() causes the bus infrastructure to look for a
334334
* matching driver. */
335335
err = device_register(&dev->dev);
336+
if (err)
337+
ida_simple_remove(&virtio_index_ida, dev->index);
336338
out:
337339
if (err)
338340
virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);

0 commit comments

Comments
 (0)