diff options
author | weiping zhang <zwp10758@gmail.com> | 2017-11-29 04:23:01 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2017-12-01 17:55:32 +0300 |
commit | e60ea67bb60459b95a50a156296041a13e0e380e (patch) | |
tree | 3a84c30892f84e70e9ea5c7c24e1ee55ddb8ca0c /drivers/virtio/virtio.c | |
parent | 23f1b8d938c861ee0bbb786162f7ce0685f722ec (diff) | |
download | linux-e60ea67bb60459b95a50a156296041a13e0e380e.tar.xz |
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: weiping zhang <zhangweiping@didichuxing.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio/virtio.c')
-rw-r--r-- | drivers/virtio/virtio.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 48230a5e12f2..bf7ff3934d7f 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -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); |