* [PATCH] vdpa/ifcvf: handle dev_set_name() failure in ifcvf_vdpa_dev_add()
@ 2026-02-26 15:29 Evgenii Burenchev
2026-03-03 6:47 ` Jason Wang
2026-03-05 7:11 ` Zhu Lingshan
0 siblings, 2 replies; 3+ messages in thread
From: Evgenii Burenchev @ 2026-02-26 15:29 UTC (permalink / raw)
To: stable, Greg Kroah-Hartman
Cc: Evgenii Burenchev, lingshan.zhu, mst, jasowang, xuanzhuo,
eperezma, virtualization, linux-kernel, lvc-project
dev_set_name() may fail and return an error, but its return value
is currently ignored and overwritten by _vdpa_register_device().
Abort device creation if dev_set_name() fails and release the
device reference to avoid continuing with an improperly initialized
struct device.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
---
drivers/vdpa/ifcvf/ifcvf_main.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index d46c1606c97a..ab6d6ab3b3d8 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -734,15 +734,22 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
ret = dev_set_name(&vdpa_dev->dev, "%s", name);
else
ret = dev_set_name(&vdpa_dev->dev, "vdpa%u", vdpa_dev->index);
+ if (ret) {
+ IFCVF_ERR(pdev, "Failed to set device name");
+ goto err;
+ }
ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring);
if (ret) {
- put_device(&adapter->vdpa.dev);
IFCVF_ERR(pdev, "Failed to register to vDPA bus");
- return ret;
+ goto err;
}
return 0;
+
+err:
+ put_device(&adapter->vdpa.dev);
+ return ret;
}
static void ifcvf_vdpa_dev_del(struct vdpa_mgmt_dev *mdev, struct vdpa_device *dev)
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] vdpa/ifcvf: handle dev_set_name() failure in ifcvf_vdpa_dev_add()
2026-02-26 15:29 [PATCH] vdpa/ifcvf: handle dev_set_name() failure in ifcvf_vdpa_dev_add() Evgenii Burenchev
@ 2026-03-03 6:47 ` Jason Wang
2026-03-05 7:11 ` Zhu Lingshan
1 sibling, 0 replies; 3+ messages in thread
From: Jason Wang @ 2026-03-03 6:47 UTC (permalink / raw)
To: Evgenii Burenchev
Cc: stable, Greg Kroah-Hartman, lingshan.zhu, mst, xuanzhuo, eperezma,
virtualization, linux-kernel, lvc-project
On Thu, Feb 26, 2026 at 11:36 PM Evgenii Burenchev <evg28bur@yandex.ru> wrote:
>
> dev_set_name() may fail and return an error, but its return value
> is currently ignored and overwritten by _vdpa_register_device().
>
> Abort device creation if dev_set_name() fails and release the
> device reference to avoid continuing with an improperly initialized
> struct device.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
> ---
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vdpa/ifcvf: handle dev_set_name() failure in ifcvf_vdpa_dev_add()
2026-02-26 15:29 [PATCH] vdpa/ifcvf: handle dev_set_name() failure in ifcvf_vdpa_dev_add() Evgenii Burenchev
2026-03-03 6:47 ` Jason Wang
@ 2026-03-05 7:11 ` Zhu Lingshan
1 sibling, 0 replies; 3+ messages in thread
From: Zhu Lingshan @ 2026-03-05 7:11 UTC (permalink / raw)
To: Evgenii Burenchev
Cc: stable, Greg Kroah-Hartman, mst, jasowang, xuanzhuo, eperezma,
virtualization, linux-kernel, lvc-project
On Thu, Feb 26, 2026 at 11:31 PM Evgenii Burenchev <evg28bur@yandex.ru> wrote:
>
> dev_set_name() may fail and return an error, but its return value
> is currently ignored and overwritten by _vdpa_register_device().
>
> Abort device creation if dev_set_name() fails and release the
> device reference to avoid continuing with an improperly initialized
> struct device.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
> ---
> drivers/vdpa/ifcvf/ifcvf_main.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
> index d46c1606c97a..ab6d6ab3b3d8 100644
> --- a/drivers/vdpa/ifcvf/ifcvf_main.c
> +++ b/drivers/vdpa/ifcvf/ifcvf_main.c
> @@ -734,15 +734,22 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
> ret = dev_set_name(&vdpa_dev->dev, "%s", name);
> else
> ret = dev_set_name(&vdpa_dev->dev, "vdpa%u", vdpa_dev->index);
> + if (ret) {
> + IFCVF_ERR(pdev, "Failed to set device name");
> + goto err;
> + }
>
> ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring);
> if (ret) {
> - put_device(&adapter->vdpa.dev);
> IFCVF_ERR(pdev, "Failed to register to vDPA bus");
> - return ret;
> + goto err;
> }
>
> return 0;
> +
> +err:
> + put_device(&adapter->vdpa.dev);
> + return ret;
> }
>
> static void ifcvf_vdpa_dev_del(struct vdpa_mgmt_dev *mdev, struct vdpa_device *dev)
> --
> 2.43.0
>
Acked-by: Zhu Lingshan <lingshan.zhu@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-05 7:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 15:29 [PATCH] vdpa/ifcvf: handle dev_set_name() failure in ifcvf_vdpa_dev_add() Evgenii Burenchev
2026-03-03 6:47 ` Jason Wang
2026-03-05 7:11 ` Zhu Lingshan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox