Skip to content

Commit 72f1268

Browse files
Dan Carpenteraegl
authored andcommitted
EDAC/i5400: Fix snprintf() limit 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 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: 68d086f ("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
1 parent 7b5c7e8 commit 72f1268

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/edac/i5400_edac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,13 +1026,13 @@ static void calculate_dimm_size(struct i5400_pvt *pvt)
10261026
space -= n;
10271027
}
10281028

1029-
space -= n;
10301029
edac_dbg(2, "%s\n", mem_buffer);
10311030
p = mem_buffer;
10321031
space = PAGE_SIZE;
10331032

10341033
n = snprintf(p, space, " ");
10351034
p += n;
1035+
space -= n;
10361036
for (branch = 0; branch < MAX_BRANCHES; branch++) {
10371037
n = snprintf(p, space, " branch %d | ", branch);
10381038
p += n;

0 commit comments

Comments
 (0)