Re: [PATCH] drm/i195: Fix format string truncation warning

From: David Laight

Date: Fri Dec 05 2025 - 13:28:19 EST


On Fri, 5 Dec 2025 11:48:08 +0100
Ard Biesheuvel <ardb@xxxxxxxxxx> wrote:

> On Sun, 9 Nov 2025 at 19:00, Ard Biesheuvel <ardb@xxxxxxxxxx> wrote:
...
> > > But I guess much prettier fix would be to simply grow the buffer.
> > >
> >
>
> OK, so something like
>
> --- a/drivers/gpu/drm/i915/intel_memory_region.h
> +++ b/drivers/gpu/drm/i915/intel_memory_region.h
> @@ -72,7 +72,7 @@ struct intel_memory_region {
> u16 instance;
> enum intel_region_id id;
> char name[16];
> - char uabi_name[16];
> + char uabi_name[20];

The observant will notice the 7 bytes of padding following 'private',
and another 7 a little later on.
(I' pretty sure 'bool' is u8).

So extending the buffer doesn't even grow the structure.
The string is only used when printing some stats.
I got lost in a list of #defines and function pointers trying to find
the actual function that did the 'printf'.

David

> bool private; /* not for userspace */
>
> struct {
>
>
>
> > > Also, hm, how come gcc does not find the mem->name vsnprintf from
> > > intel_memory_region_set_name?
> > >
> >
>
> AFAICT, intel_memory_region_set_name() is never called with a format
> string that could produce more than 15/16 bytes of output.
>