armbian-build/patch/kernel/archive/wsl2-arm64-6.1/1705-drivers-hv-dxgkrnl-Add...

52 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Iouri Tarassov <iourit@linux.microsoft.com>
Date: Wed, 29 Jun 2022 10:04:23 -0700
Subject: drivers: hv: dxgkrnl: Added missed NULL check for resource object
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 | 10 ++++++----
1 file changed, 6 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
@@ -1589,7 +1589,8 @@ dxgkio_create_allocation(struct dxgprocess *process, void *__user inargs)
&process->handle_table,
HMGRENTRY_TYPE_DXGRESOURCE,
args.resource);
- kref_get(&resource->resource_kref);
+ if (resource != NULL)
+ kref_get(&resource->resource_kref);
dxgprocess_ht_lock_shared_up(process);
if (resource == NULL || resource->device != device) {
@@ -1693,10 +1694,8 @@ dxgkio_create_allocation(struct dxgprocess *process, void *__user inargs)
&standard_alloc);
cleanup:
- if (resource_mutex_acquired) {
+ if (resource_mutex_acquired)
mutex_unlock(&resource->resource_mutex);
- kref_put(&resource->resource_kref, dxgresource_release);
- }
if (ret < 0) {
if (dxgalloc) {
for (i = 0; i < args.alloc_count; i++) {
@@ -1727,6 +1726,9 @@ dxgkio_create_allocation(struct dxgprocess *process, void *__user inargs)
if (adapter)
dxgadapter_release_lock_shared(adapter);
+ if (resource && !args.flags.create_resource)
+ kref_put(&resource->resource_kref, dxgresource_release);
+
if (device) {
dxgdevice_release_lock_shared(device);
kref_put(&device->device_kref, dxgdevice_release);
--
Armbian