Skip to content

Commit 7e52b11

Browse files
Marek Vasutbebarino
authored andcommitted
clk: si521xx: Increase stack based print buffer size in probe
Increase the size of temporary print buffer on stack to fix the following warnings reported by LKP. Since all the input parameters of snprintf() are under control of this driver, it is not possible to trigger and overflow here, but since the print buffer is on stack and discarded once driver probe() finishes, it is not an issue to increase it by 10 bytes and fix the warning in the process. Make it so. " drivers/clk/clk-si521xx.c: In function 'si521xx_probe': >> drivers/clk/clk-si521xx.c:318:26: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=] snprintf(name, 6, "DIFF%d", i); ^~ drivers/clk/clk-si521xx.c:318:21: note: directive argument in the range [0, 2147483647] snprintf(name, 6, "DIFF%d", i); ^~~~~~~~ drivers/clk/clk-si521xx.c:318:3: note: 'snprintf' output between 6 and 15 bytes into a destination of size 6 snprintf(name, 6, "DIFF%d", i); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " Fixes: edc1276 ("clk: si521xx: Clock driver for Skyworks Si521xx I2C PCIe clock generators") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202310260412.AGASjFN4-lkp@intel.com/ Signed-off-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20231027085840.30098-1-marex@denx.de Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 409c39e commit 7e52b11

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/clk/clk-si521xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static int si521xx_probe(struct i2c_client *client)
282282
const u16 chip_info = (u16)(uintptr_t)i2c_get_match_data(client);
283283
const struct clk_parent_data clk_parent_data = { .index = 0 };
284284
struct si521xx *si;
285-
unsigned char name[6] = "DIFF0";
285+
unsigned char name[16] = "DIFF0";
286286
struct clk_init_data init = {};
287287
int i, ret;
288288

@@ -315,7 +315,7 @@ static int si521xx_probe(struct i2c_client *client)
315315
/* Register clock */
316316
for (i = 0; i < hweight16(chip_info); i++) {
317317
memset(&init, 0, sizeof(init));
318-
snprintf(name, 6, "DIFF%d", i);
318+
snprintf(name, sizeof(name), "DIFF%d", i);
319319
init.name = name;
320320
init.ops = &si521xx_diff_clk_ops;
321321
init.parent_data = &clk_parent_data;

0 commit comments

Comments
 (0)