qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/pci: Fix a use-after-free issue
@ 2023-05-16  3:43 Zhenzhong Duan
  2023-05-16  8:57 ` Cédric Le Goater
  0 siblings, 1 reply; 4+ messages in thread
From: Zhenzhong Duan @ 2023-05-16  3:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: minwoo.im, alex.williamson, clg, chao.p.peng

We should free the duplicated variant of vbasedev->name plus uuid
rather than vbasedev->name itself.

Fixes: 2dca1b37a7 ("vfio/pci: add support for VF toke")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 hw/vfio/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index bf27a3990564..d2593681e000 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2998,7 +2998,9 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
     }
 
     ret = vfio_get_device(group, name, vbasedev, errp);
-    g_free(name);
+    if (name != vbasedev->name) {
+        g_free(name);
+    }
     if (ret) {
         vfio_put_group(group);
         goto error;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-16 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-16  3:43 [PATCH] vfio/pci: Fix a use-after-free issue Zhenzhong Duan
2023-05-16  8:57 ` Cédric Le Goater
2023-05-16 10:02   ` Duan, Zhenzhong
2023-05-16 18:59     ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).