diff options
author | Zhenzhong Duan <zhenzhong.duan@intel.com> | 2023-05-17 10:46:51 +0800 |
---|---|---|
committer | Cédric Le Goater <clg@redhat.com> | 2023-05-24 09:21:22 +0200 |
commit | b83b40b614846b86e69f1680aec379594dc77d6b (patch) | |
tree | 1c722784b9eb80711a9b57f588ed89fd48009b81 /hw/vfio | |
parent | aa33508196f4e2da04625bee36e1f7be5b9267e7 (diff) | |
download | qemu-b83b40b614846b86e69f1680aec379594dc77d6b.zip qemu-b83b40b614846b86e69f1680aec379594dc77d6b.tar.gz qemu-b83b40b614846b86e69f1680aec379594dc77d6b.tar.bz2 |
vfio/pci: Fix a use-after-free issue
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: 2dca1b37a760 ("vfio/pci: add support for VF token")
Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio')
-rw-r--r-- | hw/vfio/pci.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index bf27a39..73874a9 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); |