Re: [PATCH v1 1/1] leds: pca955x: Avoid potential overflow when filling default_label

From: Andy Shevchenko
Date: Sun Apr 06 2025 - 08:37:49 EST


On Sat, Apr 05, 2025 at 02:58:17AM +0800, kernel test robot wrote:
> Hi Andy,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on v6.14]
> [cannot apply to lee-leds/for-leds-next linus/master next-20250404]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/leds-pca955x-Avoid-potential-overflow-when-filling-default_label/20250405-003054
> base: v6.14
> patch link: https://lore.kernel.org/r/20250404162849.3650361-1-andriy.shevchenko%40linux.intel.com
> patch subject: [PATCH v1 1/1] leds: pca955x: Avoid potential overflow when filling default_label
> config: powerpc-randconfig-003-20250405 (https://download.01.org/0day-ci/archive/20250405/202504050256.SYq06TxB-lkp@xxxxxxxxx/config)
> compiler: powerpc-linux-gcc (GCC) 8.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250405/202504050256.SYq06TxB-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202504050256.SYq06TxB-lkp@xxxxxxxxx/
>
> All warnings (new ones prefixed by >>):
>
> drivers/leds/leds-pca955x.c: In function 'pca955x_probe':
> >> drivers/leds/leds-pca955x.c:554:53: warning: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Wformat-truncation=]
> snprintf(default_label, sizeof(default_label), "%u", i);
> ^~
> drivers/leds/leds-pca955x.c:554:52: note: directive argument in the range [0, 4294967294]
> snprintf(default_label, sizeof(default_label), "%u", i);
> ^~~~
> drivers/leds/leds-pca955x.c:554:5: note: 'snprintf' output between 2 and 11 bytes into a destination of size 8
> snprintf(default_label, sizeof(default_label), "%u", i);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Nice, different GCC have different level of issue here. I will address this
in v2.

--
With Best Regards,
Andy Shevchenko