[PATCH 1/1] drm/xe: Add NULL check before dereferencing pointer lrc->bo in xe_lrc_snapshot_capture()
apoorva.singh at intel.com
apoorva.singh at intel.com
Tue Aug 20 08:54:54 UTC 2024
From: Apoorva Singh <apoorva.singh at intel.com>
Add NULL check before deferencing of lrc->bo in
xe_lrc_snapshot_capture().
Free the dynamically allocated memory for snapshot
to avoid memory leak.
Signed-off-by: Apoorva Singh <apoorva.singh at intel.com>
---
drivers/gpu/drm/xe/xe_lrc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
index 974a9cd8c379..8ab1af4b4057 100644
--- a/drivers/gpu/drm/xe/xe_lrc.c
+++ b/drivers/gpu/drm/xe/xe_lrc.c
@@ -1649,7 +1649,12 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
if (!snapshot)
return NULL;
- if (lrc->bo && lrc->bo->vm)
+ if (!lrc->bo) {
+ kfree(snapshot);
+ return NULL;
+ }
+
+ if (lrc->bo->vm)
xe_vm_get(lrc->bo->vm);
snapshot->context_desc = xe_lrc_ggtt_addr(lrc);
--
2.34.1
More information about the Intel-xe
mailing list