drm/radeon: avoid printing NULL strings
Subsystems (2)
PATCH 1/1 drm/radeon: avoid printing NULL strings
From: Arnd Bergmann <[email protected]>
gcc-10 warns about some printf format strings that are used to unconditionally print a NULL string pointer from some call sites:
In function 'evergreen_surface_check',
inlined from 'evergreen_cs_track_validate_stencil' at drivers/gpu/drm/radeon/evergreen_cs.c:592:6, inlined from 'evergreen_cs_track_check' at drivers/gpu/drm/radeon/evergreen_cs.c:995:8:include/linux/dev_printk.h:156:24: error: '%s' directive argument is null [-Werror=format-overflow=]
156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)
This is harmless here because the kernel prints them as "(null)", but still breaks the build when compiling with -Werror.
Pass empty strings instead to avoid these warnings.
--- drivers/gpu/drm/radeon/evergreen_cs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/evergreen_cs.c +3 -3
@@ -589,7 +589,7 @@ static int evergreen_cs_track_validate_stencil(struct radeon_cs_parser *p)return r; } - r =evergreen_surface_check (p, &surf,NULL ); + r =evergreen_surface_check (p, &surf,"" );if (r) {/* old userspace doesn't compute proper depth/stencil alignment * check that alignment against a bigger byte per elements and
@@ -818,7 +818,7 @@ static int evergreen_cs_track_validate_texture(struct radeon_cs_parser *p, }/* align height */ -evergreen_surface_check (p, &surf,NULL ); +evergreen_surface_check (p, &surf,"" ); surf.nby =ALIGN (surf.nby, surf.halign); r =evergreen_surface_check (p, &surf,"texture" );
@@ -881,7 +881,7 @@ static int evergreen_cs_track_validate_texture(struct radeon_cs_parser *p, surf.mode =ARRAY_1D_TILED_THIN1 ; }/* recompute alignment */ -evergreen_surface_check (p, &surf,NULL ); +evergreen_surface_check (p, &surf,"" );break ;case ARRAY_LINEAR_GENERAL :case ARRAY_LINEAR_ALIGNED :
Signature · 1 line
2.39.5
PATCH 1/1 drm/radeon/evergreen_cs: Add missing NULL prefix check in surface check
'evergreen_surface_check' is called with a NULL warning prefix when handling potentially recoverable issues or just to compute the alignment requirements, and 'evergreen_surface_check' is called again in case of failure (with the correct prefix, as opposed to NULL), therefore, the initial check must not print a warning, because the surface may be accepted successfully after having been corrected, however if it isn't, the final check will print the warning anyway. The surface check functions specific to array modes already implement this behavior, but the 'evergreen_surface_check' function itself doesn't.
This is also supposed to fix the "'%s' directive argument is null [-Werror=format-overflow=]" compiler warning.
--- drivers/gpu/drm/radeon/evergreen_cs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/evergreen_cs.c +4 -2
@@ -312,8 +312,10 @@ static int evergreen_surface_check(struct radeon_cs_parser *p,case ARRAY_2D_TILED_THIN1 :return evergreen_surface_check_2d (p, surf, prefix);default : -dev_warn (p->dev,"%s:%d %s invalid array mode %d\n" , - __func__, __LINE__, prefix, surf->mode); +if (prefix) { +dev_warn (p->dev,"%s:%d %s invalid array mode %d\n" , + __func__, __LINE__, prefix, surf->mode); + }return -EINVAL ; }return -EINVAL ;
Signature · 1 line
2.43.0
Nice catch, but NAK on the proposed solution.
The NULL prefix is passed to 'evergreen_surface_check' intentionally to disable printing the warnings, and explicitly handled, but there's one place where the NULL check was likely forgotten.
I've proposed a patch adding it there with a detailed explanation:
https://lists.freedesktop.org/archives/amd-gfx/2026-May/144615.html
PATCH 1/1 drm/radeon/evergreen_cs: Add missing NULL prefix check in surface check
In reply to Arnd Bergmann'evergreen_surface_check' is called with a NULL warning prefix when handling potentially recoverable issues or just to compute the alignment requirements, and 'evergreen_surface_check' is called again in case of failure (with the correct prefix, as opposed to NULL), therefore, the initial check must not print a warning, because the surface may be accepted successfully after having been corrected, however if it isn't, the final check will print the warning anyway. The surface check functions specific to array modes already implement this behavior, but the 'evergreen_surface_check' function itself doesn't.
This is also supposed to fix the "'%s' directive argument is null [-Werror=format-overflow=]" compiler warning.
--- drivers/gpu/drm/radeon/evergreen_cs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/evergreen_cs.c +4 -2
@@ -312,8 +312,10 @@ static int evergreen_surface_check(struct radeon_cs_parser *p,case ARRAY_2D_TILED_THIN1 :return evergreen_surface_check_2d (p, surf, prefix);default : -dev_warn (p->dev,"%s:%d %s invalid array mode %d\n" , - __func__, __LINE__, prefix, surf->mode); +if (prefix) { +dev_warn (p->dev,"%s:%d %s invalid array mode %d\n" , + __func__, __LINE__, prefix, surf->mode); + }return -EINVAL ; }return -EINVAL ;
Signature · 1 line
2.43.0
Alex Deucher
AppliedRe: [PATCH] drm/radeon/evergreen_cs: Add missing NULL prefix check in surface check
Applied. Thanks!
Quoted 41 lines · On Mon, May 18, 2026 at 6:29 AM Vitaliy Triang3l Kuzmin <[email protected]> wrote:
'
evergreen_surface_check' is called with a NULL warning prefix when handling potentially recoverable issues or just to compute the alignment requirements, and 'evergreen_surface_check' is called again in case of failure (with the correct prefix, as opposed to NULL), therefore, the initial check must not print a warning, because the surface may be accepted successfully after having been corrected, however if it isn't, the final check will print the warning anyway. The surface check functions specific to array modes already implement this behavior, but the 'evergreen_surface_check' function itself doesn't.This is also supposed to fix the "'%s' directive argument is null [-Werror=format-overflow=]" compiler warning.
Fixes 285484e2d55e ("drm/radeon: add support for evergreen/ni tiling informations v11")Reported-by Arnd Bergmann <[email protected]>Signed-off-by Vitaliy Triang3l Kuzmin <[email protected]>--- drivers/gpu/drm/radeon/evergreen_cs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/evergreen_cs.c +4
-3@@ -312,8 +312,10 @@ static int evergreen_surface_check(struct radeon_cs_parser *p,case ARRAY_2D_TILED_THIN1 :return evergreen_surface_check_2d (p, surf, prefix);default : -dev_warn (p->dev,"%s:%d %s invalid array mode %d\n" , - __func__, __LINE__, prefix, surf->mode); +if (prefix) { +dev_warn (p->dev,"%s:%d %s invalid array mode %d\n" , + __func__, __LINE__, prefix, surf->mode); + }return -EINVAL ; }return -EINVAL ; --2.43.0