Files
build/patch/kernel/archive/wsl2-arm64-6.6/1703-drivers-hv-dxgkrnl-Close-shared-file-objects-in-case-of-a-failure.patch
2025-01-05 10:15:14 +01:00

81 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Iouri Tarassov <iourit@linux.microsoft.com>
Date: Tue, 28 Jun 2022 17:26:11 -0700
Subject: drivers: hv: dxgkrnl: Close shared file objects in case of a failure
Signed-off-by: Iouri Tarassov <iourit@linux.microsoft.com>
[kms: Forward port to v6.1]
Signed-off-by: Kelsey Steele <kelseysteele@microsoft.com>
---
drivers/hv/dxgkrnl/ioctl.c | 14 +++++++---
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/hv/dxgkrnl/ioctl.c b/drivers/hv/dxgkrnl/ioctl.c
index 111111111111..222222222222 100644
--- a/drivers/hv/dxgkrnl/ioctl.c
+++ b/drivers/hv/dxgkrnl/ioctl.c
@@ -4536,7 +4536,7 @@ enum dxg_sharedobject_type {
};
static int get_object_fd(enum dxg_sharedobject_type type,
- void *object, int *fdout)
+ void *object, int *fdout, struct file **filp)
{
struct file *file;
int fd;
@@ -4565,8 +4565,8 @@ static int get_object_fd(enum dxg_sharedobject_type type,
return -ENOTRECOVERABLE;
}
- fd_install(fd, file);
*fdout = fd;
+ *filp = file;
return 0;
}
@@ -4581,6 +4581,7 @@ dxgkio_share_objects(struct dxgprocess *process, void *__user inargs)
struct dxgsharedresource *shared_resource = NULL;
struct d3dkmthandle *handles = NULL;
int object_fd = -1;
+ struct file *filp = NULL;
void *obj = NULL;
u32 handle_size;
int ret;
@@ -4660,7 +4661,7 @@ dxgkio_share_objects(struct dxgprocess *process, void *__user inargs)
switch (object_type) {
case HMGRENTRY_TYPE_DXGSYNCOBJECT:
ret = get_object_fd(DXG_SHARED_SYNCOBJECT, shared_syncobj,
- &object_fd);
+ &object_fd, &filp);
if (ret < 0) {
DXG_ERR("get_object_fd failed for sync object");
goto cleanup;
@@ -4675,7 +4676,7 @@ dxgkio_share_objects(struct dxgprocess *process, void *__user inargs)
break;
case HMGRENTRY_TYPE_DXGRESOURCE:
ret = get_object_fd(DXG_SHARED_RESOURCE, shared_resource,
- &object_fd);
+ &object_fd, &filp);
if (ret < 0) {
DXG_ERR("get_object_fd failed for resource");
goto cleanup;
@@ -4708,10 +4709,15 @@ dxgkio_share_objects(struct dxgprocess *process, void *__user inargs)
if (ret) {
DXG_ERR("failed to copy shared handle");
ret = -EFAULT;
+ goto cleanup;
}
+ fd_install(object_fd, filp);
+
cleanup:
if (ret < 0) {
+ if (filp)
+ fput(filp);
if (object_fd >= 0)
put_unused_fd(object_fd);
}
--
Armbian