diff options
author | Bo Liu <liubo03@inspur.com> | 2022-07-06 23:17:51 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2022-08-11 04:26:07 -0400 |
commit | 95bf9798779af166b1d6d184d794834214a1a261 (patch) | |
tree | 55499c3ced73d210edda7233b6cc3fce6aaa8590 /drivers/virtio/virtio.c | |
parent | d650f830f38b19039958f3f4504ceeb2b5922da7 (diff) |
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.c | 4 |
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) |