Skip to contentSkip to conversation

drm/xe/devcoredump: Remove IS_ERR_OR_NULL check for kzalloc

PATCH In review Shuicheng Lin 3 participants 3 messages Feb 19, 2025

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

PATCH 1/1 drm/xe/devcoredump: Remove IS_ERR_OR_NULL check for kzalloc

kzalloc returns a valid pointer or NULL if the allocation fails. It never returns an error pointer. It is better to check for NULL directly.

Cc John Harrison <[email protected]>
Cc Lucas De Marchi <[email protected]>
---
 drivers/gpu/drm/xe/xe_devcoredump.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_devcoredump.c +2 -2
index 60d15e455017..81b9d9bb3f57 100644
@@ -426,8 +426,8 @@ void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix, char suffi
 		drm_printf(p, "Offset not word aligned: %zu", offset);
 
 	line_buff = kzalloc(DMESG_MAX_LINE_LEN, GFP_KERNEL);
-	if (IS_ERR_OR_NULL(line_buff)) {
-		drm_printf(p, "Failed to allocate line buffer: %pe", line_buff);
+	if (!line_buff) {
+		drm_printf(p, "Failed to allocate line buffer\n");
 		return;
 	}
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

-----Original Message-----
From: Intel-xe <[email protected]> On Behalf Of Shuicheng Lin
Sent: Wednesday, February 19, 2025 1:43 PM
To: [email protected]
Cc: Lin, Shuicheng <[email protected]>; Harrison, John C <[email protected]>; De Marchi, Lucas <[email protected]>
Subject: [PATCH] drm/xe/devcoredump: Remove IS_ERR_OR_NULL check for kzalloc

Quoted 7 lines

kzalloc returns a valid pointer or NULL if the allocation fails. It never returns an error pointer. It is better to check for NULL directly.

Cc John Harrison <[email protected]>
Cc Lucas De Marchi <[email protected]>

LGTM.

-Jonathan Cavitt

Quoted 23 lines
---
 drivers/gpu/drm/xe/xe_devcoredump.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_devcoredump.c +2 -2
index 60d15e455017..81b9d9bb3f57 100644
@@ -426,8 +426,8 @@ void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix, char suffi
 		drm_printf(p, "Offset not word aligned: %zu", offset);
 
 	line_buff = kzalloc(DMESG_MAX_LINE_LEN, GFP_KERNEL);
-	if (IS_ERR_OR_NULL(line_buff)) {
-		drm_printf(p, "Failed to allocate line buffer: %pe", line_buff);
+	if (!line_buff) {
+		drm_printf(p, "Failed to allocate line buffer\n");
 		return;
 	}
 
Signature · 1 line
2.25.1
#2 lore raw

✗ CI.Patch_applied: failure for drm/xe/devcoredump: Remove IS_ERR_OR_NULL check for kzalloc

In reply to Shuicheng Lin
== Series Details ==

== Series Details ==

Series: drm/xe/devcoredump: Remove IS_ERR_OR_NULL check for kzalloc
URL : https://patchwork.freedesktop.org/series/145129/
State : failure

== Summary ==

=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: e19eb43c8248 drm-tip: 2025y-02m-19d-19h-43m-10s UTC integration manifest === git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_devcoredump.c:426
error: drivers/gpu/drm/xe/xe_devcoredump.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: drm/xe/devcoredump: Remove IS_ERR_OR_NULL check for kzalloc Patch failed at 0001 drm/xe/devcoredump: Remove IS_ERR_OR_NULL check for kzalloc When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".