summaryrefslogtreecommitdiff
path: root/drivers/edac
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2025-12-09 17:37:04 +0300
committerSasha Levin <sashal@kernel.org>2026-03-04 07:19:32 -0500
commitc60e172982f2f73eae02dafa549abfff4b5c6110 (patch)
tree22d1cbbd473906c72c3fb29ec64977361d25874d /drivers/edac
parentbe82a2d984b66bb3adb533000a623c135948ea28 (diff)
downloadlinux-c60e172982f2f73eae02dafa549abfff4b5c6110.tar.gz
linux-c60e172982f2f73eae02dafa549abfff4b5c6110.tar.bz2
linux-c60e172982f2f73eae02dafa549abfff4b5c6110.zip
EDAC/i5400: Fix snprintf() limit calculation in calculate_dimm_size()
[ Upstream commit 72f12683611344853ab030fe7d19b23970ed2bd8 ] The snprintf() can't really overflow because we're writing a max of 42 bytes to a PAGE_SIZE buffer. But my static checker complains because the limit calculation doesn't take the first 11 space characters that we wrote into the buffer into consideration. Fix this for the sake of correctness even though it doesn't affect runtime. Also delete an earlier "space -= n;" which was not used. Fixes: 68d086f89b80 ("i5400_edac: improve debug messages to better represent the filled memory") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Link: https://patch.msgid.link/ccd06b91748e7ed8e33eeb2ff1e7b98700879304.1765290801.git.dan.carpenter@linaro.org Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/i5400_edac.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/edac/i5400_edac.c b/drivers/edac/i5400_edac.c
index f76624ee82ef..5b1188f1b570 100644
--- a/drivers/edac/i5400_edac.c
+++ b/drivers/edac/i5400_edac.c
@@ -1024,13 +1024,13 @@ static void calculate_dimm_size(struct i5400_pvt *pvt)
space -= n;
}
- space -= n;
edac_dbg(2, "%s\n", mem_buffer);
p = mem_buffer;
space = PAGE_SIZE;
n = snprintf(p, space, " ");
p += n;
+ space -= n;
for (branch = 0; branch < MAX_BRANCHES; branch++) {
n = snprintf(p, space, " branch %d | ", branch);
p += n;