[PATCH RFC POC 46/50] xen/gntdev-dmabuf: stop putting the descriptor back on failure
COLD16d
From: Christian Brauner <brauner@kernel.org>
Date: 2026-09-15 11:37:17
Also in:
bpf, dri-devel, io-uring, kexec, kvm, linux-alpha, linux-arm-kernel, linux-arm-msm, linux-fsdevel, linux-gpio, linux-hyperv, linux-m68k, linux-mips, linux-mm, linux-sh, linux-um, linuxppc-dev, lkml, sparclinux, virtualization
Subsystem:
the rest, xen hypervisor interface · Maintainers:
Linus Torvalds, Juergen Gross, Stefano Stabellini
Rely on the fd exit path machinery.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
drivers/xen/gntdev-dmabuf.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
index 83b0df460894..a3ecc7c83974 100644
--- a/drivers/xen/gntdev-dmabuf.c
+++ b/drivers/xen/gntdev-dmabuf.c
@@ -357,10 +357,10 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
{
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
struct gntdev_dmabuf *gntdev_dmabuf __free(kfree) = NULL;
- CLASS(get_unused_fd, ret)(O_CLOEXEC);
+ const struct fd_slot *fd = fd_prepare(O_CLOEXEC);
- if (ret < 0)
- return ret;
+ if (IS_ERR(fd))
+ return PTR_ERR(fd);
gntdev_dmabuf = kzalloc_obj(*gntdev_dmabuf);
if (!gntdev_dmabuf)@@ -388,17 +388,17 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
if (IS_ERR(gntdev_dmabuf->dmabuf))
return PTR_ERR(gntdev_dmabuf->dmabuf);
- gntdev_dmabuf->fd = ret;
- args->fd = ret;
+ gntdev_dmabuf->fd = fd_prepare_fd(fd);
+ args->fd = fd_prepare_fd(fd);
- pr_debug("Exporting DMA buffer with fd %d\n", ret);
+ pr_debug("Exporting DMA buffer with fd %d\n", fd_prepare_fd(fd));
get_file(gntdev_dmabuf->priv->filp);
mutex_lock(&args->dmabuf_priv->lock);
list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
mutex_unlock(&args->dmabuf_priv->lock);
- fd_install(take_fd(ret), no_free_ptr(gntdev_dmabuf)->dmabuf->file);
+ fd_stage(fd, no_free_ptr(gntdev_dmabuf)->dmabuf->file);
return 0;
}
--
2.53.0