On Thu, Jul 7, 2022 at 11:18 AM Bo Liu <liubo03 at inspur.com>
wrote:>
> It's possible that dev_set_name() returns -ENOMEM, catch and handle
this.
>
> Signed-off-by: Bo Liu <liubo03 at inspur.com>
Acked-by: Jason Wang <jasowang at redhat.com>
> ---
> drivers/virtio/virtio.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> 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)
> --
> 2.27.0
>