[PATCH] drm/xe/devcoredump: Remove IS_ERR_OR_NULL check for kzalloc

Cavitt, Jonathan jonathan.cavitt at intel.com
Wed Feb 19 22:28:35 UTC 2025


-----Original Message-----
From: Intel-xe <intel-xe-bounces at lists.freedesktop.org> On Behalf Of Shuicheng Lin
Sent: Wednesday, February 19, 2025 1:43 PM
To: intel-xe at lists.freedesktop.org
Cc: Lin, Shuicheng <shuicheng.lin at intel.com>; Harrison, John C <john.c.harrison at intel.com>; De Marchi, Lucas <lucas.demarchi at intel.com>
Subject: [PATCH] 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.
> 
> Signed-off-by: Shuicheng Lin <shuicheng.lin at intel.com>
> Cc: John Harrison <John.C.Harrison at Intel.com>
> Cc: Lucas De Marchi <lucas.demarchi at intel.com>

LGTM.
Reviewed-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
-Jonathan Cavitt

> ---
>  drivers/gpu/drm/xe/xe_devcoredump.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
> index 60d15e455017..81b9d9bb3f57 100644
> --- a/drivers/gpu/drm/xe/xe_devcoredump.c
> +++ b/drivers/gpu/drm/xe/xe_devcoredump.c
> @@ -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;
>  	}
>  
> -- 
> 2.25.1
> 
> 


More information about the Intel-xe mailing list