Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/xe/xe_devcoredump: Check NULL before dereferencing
@ 2024-03-22  3:58 Himal Prasad Ghimiray
  2024-03-22  5:39 ` ✓ CI.Patch_applied: success for drm/xe/xe_devcoredump: Check NULL before dereferencing (rev2) Patchwork
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Himal Prasad Ghimiray @ 2024-03-22  3:58 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)

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 | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
index 7d3aa6bd3524..5b7be3b5b906 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump.c
+++ b/drivers/gpu/drm/xe/xe_devcoredump.c
@@ -77,17 +77,22 @@ 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 -ENODATA;
+
+	xe = coredump_to_xe(coredump);
+	if (!xe)
 		return -ENODEV;
 
+	ss = &coredump->snapshot;
+
 	/* Ensure delayed work is captured before continuing */
 	flush_work(&ss->work);
 
-- 
2.25.1


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

end of thread, other threads:[~2024-03-22 16:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-22  3:58 [PATCH v3] drm/xe/xe_devcoredump: Check NULL before dereferencing Himal Prasad Ghimiray
2024-03-22  5:39 ` ✓ CI.Patch_applied: success for drm/xe/xe_devcoredump: Check NULL before dereferencing (rev2) Patchwork
2024-03-22  5:39 ` ✓ CI.checkpatch: " Patchwork
2024-03-22  5:40 ` ✓ CI.KUnit: " Patchwork
2024-03-22  5:51 ` ✓ CI.Build: " Patchwork
2024-03-22  5:53 ` ✓ CI.Hooks: " Patchwork
2024-03-22  5:55 ` ✓ CI.checksparse: " Patchwork
2024-03-22  6:21 ` ✓ CI.BAT: " Patchwork
2024-03-22 13:57 ` [PATCH v3] drm/xe/xe_devcoredump: Check NULL before dereferencing Souza, Jose
2024-03-22 15:50   ` Rodrigo Vivi
2024-03-22 16:08     ` Souza, Jose
2024-03-22 16:53       ` Rodrigo Vivi

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