mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
leds: pca955x: Avoid potential overflow when filling default_label (take 2)
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: bd3d149329 ("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>
Link: https://lore.kernel.org/r/20250630093906.1715800-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
committed by
Lee Jones
parent
cb335325b1
commit
239afba8b9
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user