Skip to contentSkip to conversation

edac: Use scnprintf() for safer buffer handling

PATCH In review Wang Haoran 2 participants 2 messages Jul 13, 2025 – Jul 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 edac: Use scnprintf() for safer buffer handling

snprintf() is fragile when its return value will be used to append additional data to a buffer. Use scnprintf() instead.

---
 drivers/edac/skx_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/skx_common.c +2 -2
index c9ade45c1a99..39c733dbc5b9 100644
@@ -670,12 +670,12 @@ static void skx_mce_output_error(struct mem_ctl_info *mci,
 	}
 
 	if (res->decoded_by_adxl) {
-		len = snprintf(skx_msg, MSG_SIZE, "%s%s err_code:0x%04x:0x%04x %s",
+		len = scnprintf(skx_msg, MSG_SIZE, "%s%s err_code:0x%04x:0x%04x %s",
 			 overflow ? " OVERFLOW" : "",
 			 (uncorrected_error && recoverable) ? " recoverable" : "",
 			 mscod, errcode, adxl_msg);
 	} else {
-		len = snprintf(skx_msg, MSG_SIZE,
+		len = scnprintf(skx_msg, MSG_SIZE,
 			 "%s%s err_code:0x%04x:0x%04x ProcessorSocketId:0x%x MemoryControllerId:0x%x PhysicalRankId:0x%x Row:0x%x Column:0x%x Bank:0x%x BankGroup:0x%x",
 			 overflow ? " OVERFLOW" : "",
 			 (uncorrected_error && recoverable) ? " recoverable" : "",
Signature · 1 line
2.43.0
#1 lore raw
Quoted 8 lines

From: Wang Haoran <[email protected]>
Sent: Sunday, July 13, 2025 10:58 AM
To: Luck, Tony <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Wang Haoran <[email protected]>
Subject: [PATCH] edac: Use scnprintf() for safer buffer handling

Quoted 6 lines

snprintf() is fragile when its return value will be used to append additional data to a buffer. Use scnprintf() instead.

---
 drivers/edac/skx_common.c | 4 ++--

Please also replace all instances of snprintf() with scnprintf() in the file drivers/edac/i10nm_edac.c

Thanks
-Qiuxu