* [PATCH] virtio: free device name when the driver is not configured
@ 2026-10-27 18:52 Yuho Choi
2026-10-28 7:37 ` Simon Glass
0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-10-27 18:52 UTC (permalink / raw)
To: Bin Meng; +Cc: Tom Rini, Tuomas Tynkkynen, Simon Glass, u-boot, Yuho Choi
virtio_uclass_post_probe() duplicates the name for the child device with
strdup() and passes it to device_bind_driver(). If the driver for the
reported device type is not built, device_bind_driver() returns -ENOENT
and the function returns 0 without freeing the name. Ownership of the
name only passes to the device through device_set_name_alloced() after
a successful bind.
This happens on each probe of a virtio transport whose device type is
listed in virtio_drv_name[] but whose driver is disabled, e.g. a
virtio-9p device on a QEMU target without CONFIG_VIRTIO_9P, or the
virtio-blk node of the sandbox test device tree, as sandbox_defconfig
does not enable CONFIG_VIRTIO_BLK.
Free the name on this path as well.
Fixes: 8fb49b4c7a82 ("dm: Add a new uclass driver for VirtIO transport devices")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
drivers/virtio/virtio-uclass.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
index c163b2fd7d5..e745369b257 100644
--- a/drivers/virtio/virtio-uclass.c
+++ b/drivers/virtio/virtio-uclass.c
@@ -239,6 +239,7 @@ static int virtio_uclass_post_probe(struct udevice *udev)
ret = device_bind_driver(udev, name, str, &vdev);
if (ret == -ENOENT) {
debug("(%s): %s driver not configured\n", udev->name, name);
+ free(str);
return 0;
}
if (ret) {
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] virtio: free device name when the driver is not configured
2026-10-27 18:52 [PATCH] virtio: free device name when the driver is not configured Yuho Choi
@ 2026-10-28 7:37 ` Simon Glass
0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2026-10-28 7:37 UTC (permalink / raw)
To: oss.patchbox; +Cc: Bin Meng, Tom Rini, Tuomas Tynkkynen, Simon Glass, u-boot
On 2026-10-27T18:52:31, Yuho Choi <oss.patchbox@gmail.com> wrote:
> virtio: free device name when the driver is not configured
>
> virtio_uclass_post_probe() duplicates the name for the child device with
> strdup() and passes it to device_bind_driver(). If the driver for the
> reported device type is not built, device_bind_driver() returns -ENOENT
> and the function returns 0 without freeing the name. Ownership of the
> name only passes to the device through device_set_name_alloced() after
> a successful bind.
>
> This happens on each probe of a virtio transport whose device type is
> listed in virtio_drv_name[] but whose driver is disabled, e.g. a
> virtio-9p device on a QEMU target without CONFIG_VIRTIO_9P, or the
> virtio-blk node of the sandbox test device tree, as sandbox_defconfig
> does not enable CONFIG_VIRTIO_BLK.
>
> Free the name on this path as well.
>
> Fixes: 8fb49b4c7a82 ("dm: Add a new uclass driver for VirtIO transport devices")
> Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
>
> drivers/virtio/virtio-uclass.c | 1 +
> 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-28 7:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 18:52 [PATCH] virtio: free device name when the driver is not configured Yuho Choi
2026-10-28 7:37 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.