virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio: release virtio index when fail to device_register
@ 2017-11-29  1:23 weiping zhang
  2017-11-29  9:50 ` Cornelia Huck
  2017-11-29 13:55 ` Michael S. Tsirkin
  0 siblings, 2 replies; 8+ messages in thread
From: weiping zhang @ 2017-11-29  1:23 UTC (permalink / raw)
  To: mst, jasowang; +Cc: virtualization

index can be reused by other virtio device.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 drivers/virtio/virtio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 48230a5..bf7ff39 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);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] virtio: release virtio index when fail to device_register
@ 2017-11-28 15:43 weiping zhang
  0 siblings, 0 replies; 8+ messages in thread
From: weiping zhang @ 2017-11-28 15:43 UTC (permalink / raw)
  To: mst, jasowang; +Cc: virtualization

index can be reused by other virtio device.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 drivers/virtio/virtio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 48230a5..bf7ff39 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);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-12-05  1:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-29  1:23 [PATCH] virtio: release virtio index when fail to device_register weiping zhang
2017-11-29  9:50 ` Cornelia Huck
2017-12-01 16:55   ` weiping zhang
2017-12-01 17:30     ` weiping zhang
2017-12-04  9:38     ` Cornelia Huck
2017-12-05  1:30       ` weiping zhang
2017-11-29 13:55 ` Michael S. Tsirkin
  -- strict thread matches above, loose matches on Subject: below --
2017-11-28 15:43 weiping zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).