Skip to content

Commit 7ccddc4

Browse files
aeglKAGA-KOKO
authored andcommitted
x86/mce/dev-mcelog: Fix -Wstringop-truncation warning about strncpy()
The kbuild test robot reported this warning: arch/x86/kernel/cpu/mce/dev-mcelog.c: In function 'dev_mcelog_init_device': arch/x86/kernel/cpu/mce/dev-mcelog.c:346:2: warning: 'strncpy' output \ truncated before terminating nul copying 12 bytes from a string of the \ same length [-Wstringop-truncation] This is accurate, but I don't care that the trailing NUL character isn't copied. The string being copied is just a magic number signature so that crash dump tools can be sure they are decoding the right blob of memory. Use memcpy() instead of strncpy(). Fixes: d8ecca4 ("x86/mce/dev-mcelog: Dynamically allocate space for machine check records") Reported-by: kbuild test robot <[email protected]> Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 17fae12 commit 7ccddc4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/cpu/mce/dev-mcelog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static __init int dev_mcelog_init_device(void)
349349
if (!mcelog)
350350
return -ENOMEM;
351351

352-
strncpy(mcelog->signature, MCE_LOG_SIGNATURE, sizeof(mcelog->signature));
352+
memcpy(mcelog->signature, MCE_LOG_SIGNATURE, sizeof(mcelog->signature));
353353
mcelog->len = mce_log_len;
354354
mcelog->recordlen = sizeof(struct mce);
355355

0 commit comments

Comments
 (0)