[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220914071050.21823-1-hbh25y@gmail.com>
Date: Wed, 14 Sep 2022 15:10:50 +0800
From: Hangyu Hua <hbh25y@...il.com>
To: bskeggs@...hat.com, kherbst@...hat.com, lyude@...hat.com,
airlied@...ux.ie, daniel@...ll.ch
Cc: dri-devel@...ts.freedesktop.org, nouveau@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, Hangyu Hua <hbh25y@...il.com>
Subject: [PATCH] drm: nouveau: move bounds checking to the front in nouveau_svm_fault_buffer_dtor()
It is better to check i before use it in array to avoid potential out of
bound access.
Signed-off-by: Hangyu Hua <hbh25y@...il.com>
---
drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 31a5b81ee9fc..5c49a8eaf593 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -957,7 +957,7 @@ nouveau_svm_fault_buffer_dtor(struct nouveau_svm *svm, int id)
int i;
if (buffer->fault) {
- for (i = 0; buffer->fault[i] && i < buffer->entries; i++)
+ for (i = 0; i < buffer->entries && buffer->fault[i]; i++)
kfree(buffer->fault[i]);
kvfree(buffer->fault);
}
--
2.34.1
Powered by blists - more mailing lists