summaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio.c
diff options
context:
space:
mode:
authorBo Liu <liubo03@inspur.com>2022-07-07 05:17:51 +0200
committerMichael S. Tsirkin <mst@redhat.com>2022-08-11 10:26:07 +0200
commit95bf9798779af166b1d6d184d794834214a1a261 (patch)
tree55499c3ced73d210edda7233b6cc3fce6aaa8590 /drivers/virtio/virtio.c
parenttools/virtio: fix build (diff)
downloadlinux-95bf9798779af166b1d6d184d794834214a1a261.tar.xz
linux-95bf9798779af166b1d6d184d794834214a1a261.zip
virtio: Check dev_set_name() return value
It's possible that dev_set_name() returns -ENOMEM, catch and handle this. Signed-off-by: Bo Liu <liubo03@inspur.com> Message-Id: <20220707031751.4802-1-liubo03@inspur.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'drivers/virtio/virtio.c')
-rw-r--r--drivers/virtio/virtio.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 7deeed30d1f3..ddd4466da83b 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -428,7 +428,9 @@ int register_virtio_device(struct virtio_device *dev)
goto out;
dev->index = err;
- dev_set_name(&dev->dev, "virtio%u", dev->index);
+ err = dev_set_name(&dev->dev, "virtio%u", dev->index);
+ if (err)
+ goto out_ida_remove;
err = virtio_device_of_init(dev);
if (err)