* [PATCH] clk: si521xx: Increase stack based print buffer size in probe
@ 2023-10-27 8:58 Marek Vasut
2023-10-27 19:20 ` Stephen Boyd
0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2023-10-27 8:58 UTC (permalink / raw)
To: linux-clk; +Cc: Marek Vasut, kernel test robot, Michael Turquette, Stephen Boyd
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: edc12763a3a2 ("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>
---
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
---
drivers/clk/clk-si521xx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk-si521xx.c b/drivers/clk/clk-si521xx.c
index 99e6271a4de14..4f7b74f889f1e 100644
--- a/drivers/clk/clk-si521xx.c
+++ b/drivers/clk/clk-si521xx.c
@@ -282,7 +282,7 @@ static int si521xx_probe(struct i2c_client *client)
const u16 chip_info = (u16)(uintptr_t)i2c_get_match_data(client);
const struct clk_parent_data clk_parent_data = { .index = 0 };
const u8 data[3] = { SI521XX_REG_BC, 1, 1 };
- unsigned char name[6] = "DIFF0";
+ unsigned char name[16] = "DIFF0";
struct clk_init_data init = {};
struct si521xx *si;
int i, ret;
@@ -316,7 +316,7 @@ static int si521xx_probe(struct i2c_client *client)
/* Register clock */
for (i = 0; i < hweight16(chip_info); i++) {
memset(&init, 0, sizeof(init));
- snprintf(name, 6, "DIFF%d", i);
+ snprintf(name, sizeof(name), "DIFF%d", i);
init.name = name;
init.ops = &si521xx_diff_clk_ops;
init.parent_data = &clk_parent_data;
--
2.42.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: si521xx: Increase stack based print buffer size in probe
2023-10-27 8:58 [PATCH] clk: si521xx: Increase stack based print buffer size in probe Marek Vasut
@ 2023-10-27 19:20 ` Stephen Boyd
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2023-10-27 19:20 UTC (permalink / raw)
To: Marek Vasut, linux-clk; +Cc: Marek Vasut, kernel test robot, Michael Turquette
Quoting Marek Vasut (2023-10-27 01:58:24)
> 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: edc12763a3a2 ("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>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-27 19:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-27 8:58 [PATCH] clk: si521xx: Increase stack based print buffer size in probe Marek Vasut
2023-10-27 19:20 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox