* [PATCH v1 1/1] leds: pca955x: Avoid potential overflow when filling default_label (take 2)
@ 2025-06-30 9:39 Andy Shevchenko
2025-07-02 16:19 ` (subset) " Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2025-06-30 9:39 UTC (permalink / raw)
To: Lee Jones, Andy Shevchenko, Eddie James, linux-leds, linux-kernel
Cc: Pavel Machek, kernel test robot
GCC compiler v8.5.0 is not happy about printing
into a too short buffer (when build with `make W=1`):
drivers/leds/leds-pca955x.c:696:5: note: 'snprintf' output between 2 and 11 bytes into a destination of size 8
Unfortunately this is a false positive from the old GCC versions,
but we may still improve the code by using '%hhu' format specifier
and reduce buffer size by 4 bytes.
Fixes: bd3d14932923 ("leds: pca955x: Avoid potential overflow when filling default_label")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202506282159.TXfvorYl-lkp@intel.com/
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/leds/leds-pca955x.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 42fe056b1c74..70d109246088 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -587,7 +587,7 @@ static int pca955x_probe(struct i2c_client *client)
struct pca955x_platform_data *pdata;
bool keep_psc0 = false;
bool set_default_label = false;
- char default_label[8];
+ char default_label[4];
int bit, err, reg;
chip = i2c_get_match_data(client);
@@ -693,7 +693,7 @@ static int pca955x_probe(struct i2c_client *client)
}
if (set_default_label) {
- snprintf(default_label, sizeof(default_label), "%u", i);
+ snprintf(default_label, sizeof(default_label), "%hhu", i);
init_data.default_label = default_label;
} else {
init_data.default_label = NULL;
--
2.47.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: (subset) [PATCH v1 1/1] leds: pca955x: Avoid potential overflow when filling default_label (take 2)
2025-06-30 9:39 [PATCH v1 1/1] leds: pca955x: Avoid potential overflow when filling default_label (take 2) Andy Shevchenko
@ 2025-07-02 16:19 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2025-07-02 16:19 UTC (permalink / raw)
To: Lee Jones, Eddie James, linux-leds, linux-kernel, Andy Shevchenko
Cc: Pavel Machek, kernel test robot
On Mon, 30 Jun 2025 12:39:06 +0300, Andy Shevchenko wrote:
> GCC compiler v8.5.0 is not happy about printing
> into a too short buffer (when build with `make W=1`):
>
> drivers/leds/leds-pca955x.c:696:5: note: 'snprintf' output between 2 and 11 bytes into a destination of size 8
>
> Unfortunately this is a false positive from the old GCC versions,
> but we may still improve the code by using '%hhu' format specifier
> and reduce buffer size by 4 bytes.
>
> [...]
Applied, thanks!
[1/1] leds: pca955x: Avoid potential overflow when filling default_label (take 2)
commit: 239afba8b9f3b0fcfd464d5ffeaed0ed4441c5a4
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-02 16:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-30 9:39 [PATCH v1 1/1] leds: pca955x: Avoid potential overflow when filling default_label (take 2) Andy Shevchenko
2025-07-02 16:19 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®