Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] drm/xe/xe_devcoredump: Check NULL before dereferencing
@ 2024-03-22 17:24 Himal Prasad Ghimiray
  2024-03-22 17:13 ` Souza, Jose
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Himal Prasad Ghimiray @ 2024-03-22 17:24 UTC (permalink / raw)
  To: intel-xe
  Cc: Himal Prasad Ghimiray, Ashutosh Dixit, José Roberto de Souza,
	Rodrigo Vivi

Dereference 'coredump' to access 'xe_devcoredump_snapshot' only if
'coredump' is not NULL,

v2
- Fix commit messages.

v3
- Define variables before code.(Ashutosh/Jose)

v4
- Drop return check for coredump_to_xe. (Jose/Rodrigo)

Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Cc: José Roberto de Souza <jose.souza@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/xe/xe_devcoredump.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
index 3a6263ecff01..a951043b2943 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump.c
+++ b/drivers/gpu/drm/xe/xe_devcoredump.c
@@ -77,17 +77,19 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
 				   size_t count, void *data, size_t datalen)
 {
 	struct xe_devcoredump *coredump = data;
-	struct xe_device *xe = coredump_to_xe(coredump);
-	struct xe_devcoredump_snapshot *ss = &coredump->snapshot;
+	struct xe_device *xe;
+	struct xe_devcoredump_snapshot *ss;
 	struct drm_printer p;
 	struct drm_print_iterator iter;
 	struct timespec64 ts;
 	int i;
 
-	/* Our device is gone already... */
-	if (!data || !coredump_to_xe(coredump))
+	if (!coredump)
 		return -ENODEV;
 
+	xe = coredump_to_xe(coredump);
+	ss = &coredump->snapshot;
+
 	/* Ensure delayed work is captured before continuing */
 	flush_work(&ss->work);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-03-28 12:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-22 17:24 [PATCH v4] drm/xe/xe_devcoredump: Check NULL before dereferencing Himal Prasad Ghimiray
2024-03-22 17:13 ` Souza, Jose
2024-03-22 17:18 ` ✓ CI.Patch_applied: success for drm/xe/xe_devcoredump: Check NULL before dereferencing (rev3) Patchwork
2024-03-22 17:18 ` ✓ CI.checkpatch: " Patchwork
2024-03-22 17:19 ` ✓ CI.KUnit: " Patchwork
2024-03-22 17:30 ` ✓ CI.Build: " Patchwork
2024-03-22 17:32 ` ✓ CI.Hooks: " Patchwork
2024-03-22 17:34 ` ✓ CI.checksparse: " Patchwork
2024-03-22 18:00 ` ✓ CI.BAT: " Patchwork
2024-03-25 17:08 ` [PATCH v4] drm/xe/xe_devcoredump: Check NULL before dereferencing Matt Roper
2024-03-28 12:11   ` Ghimiray, Himal Prasad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox