All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Subject: [PULL 08/13] hw/display/virtio-gpu: fix dmabuf_fd leak on remap failure
Date: Tue, 14 Jul 2026 21:35:12 +0200	[thread overview]
Message-ID: <20260714193517.60708-9-philmd@oss.qualcomm.com> (raw)
In-Reply-To: <20260714193517.60708-1-philmd@oss.qualcomm.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

When virtio_gpu_create_udmabuf() succeeds but virtio_gpu_remap_udmabuf()
fails (mmap returns MAP_FAILED), virtio_gpu_init_udmabuf() returns early
without closing the dmabuf fd. Since res->blob is never set in this
path, later cleanup via virtio_gpu_cleanup_mapping() skips
virtio_gpu_fini_udmabuf() entirely, leaking the file descriptor.

Call virtio_gpu_destroy_udmabuf() before the early return to close
the fd. This function already handles partial state correctly: it
skips the munmap when res->remapped is NULL and closes the fd when
res->dmabuf_fd >= 0.

Fixes: 9b60cdf98723 ("virtio-gpu: Add udmabuf helpers")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260713125622.111513-1-marcandre.lureau@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/display/virtio-gpu-udmabuf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c
index d5ac1cfca0e..5f08c855dde 100644
--- a/hw/display/virtio-gpu-udmabuf.c
+++ b/hw/display/virtio-gpu-udmabuf.c
@@ -143,6 +143,7 @@ void virtio_gpu_init_udmabuf(struct virtio_gpu_simple_resource *res)
         }
         virtio_gpu_remap_udmabuf(res);
         if (!res->remapped) {
+            virtio_gpu_destroy_udmabuf(res);
             return;
         }
         pdata = res->remapped;
-- 
2.53.0



  parent reply	other threads:[~2026-07-14 19:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 19:35 [PULL 00/13] Misc HW patches for 2026-07-14 Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 01/13] hw/sparc64/sun4u: Mark unusable PCI busses as full to ease device plugging Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 02/13] hw/misc/ivshmem: clear chardev handlers before freeing peers Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 03/13] docs/devel: Document SSI dummy-cycle ownership Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 04/13] hw/scsi/vmw_pvscsi: translate data endianness Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 05/13] hw/scsi/vmw_pvscsi: add a comment to explain the endianness Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 06/13] hw/display/qxl: fix TOCTOU in cursor chunk data_size handling Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 07/13] hw/sparc64/niagara: use int64_t for vdisk size to avoid truncation Philippe Mathieu-Daudé
2026-07-14 19:35 ` Philippe Mathieu-Daudé [this message]
2026-07-14 19:35 ` [PULL 09/13] hw/usb/hcd-ohci: Make sure that ohci_service_ed_list() cannot loop forever Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 10/13] hw/usb/hcd-xhci: Turn guest-triggerable abort() into qemu_log_mask() Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 11/13] hw/usb/hcd-xhci: Remove the FIXME macro Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 12/13] hw/usb/hcd-xhci: Use qemu_log_mask() instead of fprintf() statement Philippe Mathieu-Daudé
2026-07-14 19:35 ` [PULL 13/13] net: only advertise passt in netdev help when CONFIG_PASST Philippe Mathieu-Daudé
2026-07-17 14:50 ` [PULL 00/13] Misc HW patches for 2026-07-14 Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260714193517.60708-9-philmd@oss.qualcomm.com \
    --to=philmd@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.