virtio: Check dev_set_name() return value
authorBo Liu <liubo03@inspur.com>
Thu, 7 Jul 2022 03:17:51 +0000 (23:17 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 11 Aug 2022 08:26:07 +0000 (04:26 -0400)
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>
drivers/virtio/virtio.c

index 7deeed3..ddd4466 100644 (file)
@@ -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)