Skip to content

Commit

Permalink
virtio: Check dev_set_name() return value
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bo Liu authored and mstsirkin committed Aug 11, 2022
1 parent d650f83 commit 95bf979
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 95bf979

Please sign in to comment.