]> Gentwo Git Trees - linux/.git/commitdiff
efi/cper: Adjust infopfx size to accept an extra space
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 14 Aug 2025 16:52:53 +0000 (09:52 -0700)
committerArd Biesheuvel <ardb@kernel.org>
Fri, 21 Nov 2025 08:42:02 +0000 (09:42 +0100)
Compiling with W=1 with werror enabled produces an error:

drivers/firmware/efi/cper-arm.c: In function ‘cper_print_proc_arm’:
drivers/firmware/efi/cper-arm.c:298:64: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
  298 |                         snprintf(infopfx, sizeof(infopfx), "%s ", newpfx);
      |                                                                ^
drivers/firmware/efi/cper-arm.c:298:25: note: ‘snprintf’ output between 2 and 65 bytes into a destination of size 64
  298 |                         snprintf(infopfx, sizeof(infopfx), "%s ", newpfx);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As the logic there adds an space at the end of infopx buffer.
Add an extra space to avoid such warning.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/cper-arm.c

index f0a63d09d3c499b2f1e51d5ef35b69deeb3cbdb3..6ff781e47147c05c784ca5aa57149d1435cb2467 100644 (file)
@@ -240,7 +240,7 @@ void cper_print_proc_arm(const char *pfx,
        int i, len, max_ctx_type;
        struct cper_arm_err_info *err_info;
        struct cper_arm_ctx_info *ctx_info;
-       char newpfx[64], infopfx[64];
+       char newpfx[64], infopfx[ARRAY_SIZE(newpfx) + 1];
 
        printk("%sMIDR: 0x%016llx\n", pfx, proc->midr);