mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-18 13:21:06 +00:00
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: 68d086f89b ("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>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
committed by
Ulrich Hecht
parent
778f66b38f
commit
0748a35a7d
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user