提交 e60ea67b 编写于 作者: W weiping zhang 提交者: Michael S. Tsirkin

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: Nweiping zhang <zhangweiping@didichuxing.com>
Reviewed-by: NCornelia Huck <cohuck@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 23f1b8d9
...@@ -333,6 +333,8 @@ int register_virtio_device(struct virtio_device *dev) ...@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册