Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e60ea67b authored by weiping zhang's avatar weiping zhang Committed by Michael S. Tsirkin
Browse files

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: default avatarweiping zhang <zhangweiping@didichuxing.com>
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 23f1b8d9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);