On 5/17/23 04:46, Zhenzhong Duan wrote:
vbasedev->name is freed wrongly which leads to garbage VFIO trace log.
Fix it by allocating a dup of vbasedev->name and then free the dup.

Fixes: 2dca1b37a7 ("vfio/pci: add support for VF token")
Suggested-by: Alex Williamson <alex.william...@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com>

Reviewed-by: Cédric Le Goater <c...@redhat.com>

Thanks,

C.

---
v2: "toke" -> "token", Cedric
     Update with Alex suggested change

  hw/vfio/pci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index bf27a3990564..73874a94de12 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2994,7 +2994,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
          qemu_uuid_unparse(&vdev->vf_token, uuid);
          name = g_strdup_printf("%s vf_token=%s", vbasedev->name, uuid);
      } else {
-        name = vbasedev->name;
+        name = g_strdup(vbasedev->name);
      }
ret = vfio_get_device(group, name, vbasedev, errp);


Reply via email to