Skip to contentSkip to conversation

drivers/nouveau_svm: fix bounds check in nouveau_svm_fault_buffer_dtor

PATCH New Gaurav Singh 1 participant 1 message Aug 16, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/nouveau_svm: fix bounds check in nouveau_svm_fault_buffer_dtor

do the bounds check before accessing the buffer element.

Fixes eeaf06ac1a558 ("drm/nouveau/svm: initial support for shared virtual memory")
---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_svm.c +1 -1
index 6586d9d39874..35d24946787d 100644
@@ -897,7 +897,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);
 	}
Signature · 1 line
2.17.1