vfio/pci: Fix a use-after-free issue
authorZhenzhong Duan <zhenzhong.duan@intel.com>
Wed, 17 May 2023 02:46:51 +0000 (10:46 +0800)
committerCédric Le Goater <clg@redhat.com>
Wed, 24 May 2023 07:21:22 +0000 (09:21 +0200)
commitb83b40b614846b86e69f1680aec379594dc77d6b
tree1c722784b9eb80711a9b57f588ed89fd48009b81
parentaa33508196f4e2da04625bee36e1f7be5b9267e7
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>
hw/vfio/pci.c