Skip to content

Commit 7b5c7e8

Browse files
Dan Carpenteraegl
authored andcommitted
EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size()
The snprintf() can't really overflow because we're writing a max of 42 bytes to a PAGE_SIZE buffer. But the limit calculation doesn't take the first 11 bytes that we wrote into consideration so the limit is not correct. Just fix it for correctness even though it doesn't affect runtime. Fixes: 64e1fda ("i5000_edac: Fix the logic that retrieves memory information") 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/07cd652c51e77aad5a8350e1a7cd9407e5bbe373.1765290801.git.dan.carpenter@linaro.org
1 parent 8f0b4cc commit 7b5c7e8

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/edac/i5000_edac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt)
11111111

11121112
n = snprintf(p, space, " ");
11131113
p += n;
1114+
space -= n;
11141115
for (branch = 0; branch < MAX_BRANCHES; branch++) {
11151116
n = snprintf(p, space, " branch %d | ", branch);
11161117
p += n;

0 commit comments

Comments
 (0)