qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] vfio/pci: Fix a use-after-free issue


From: Cédric Le Goater
Subject: Re: [PATCH] vfio/pci: Fix a use-after-free issue
Date: Tue, 16 May 2023 10:57:43 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0

On 5/16/23 05:43, Zhenzhong Duan wrote:
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")

"toke" -> "token"

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) {


yes. I wonder if we shouldn't use the same test with which 'name' was
allocated instead :

    if (!qemu_uuid_is_null(&vdev->vf_token)) {

Thanks,

C.


+        g_free(name);
+    }
      if (ret) {
          vfio_put_group(group);
          goto error;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]