Re: [PATCH v3 4/4] leds: Add virtualcolor LED group driver

Dan Carpenter
2025-10-20T07:13:27Z

Hi Jonathan,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Jonathan-Brophy/dt-bindings-Add-virtualcolor-class-dt-bindings-documentation/20251019-172647
base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next
patch link: https://lore.kernel.org/r/20251019092331.49531-5-professorjonny98%40gmail.com
patch subject: [PATCH v3 4/4] leds: Add virtualcolor LED group driver
config: parisc-randconfig-r072-20251020 (https://download.01.org/0day-ci/archive/20251020/202510201457.uOrhkKly-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 8.5.0

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@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202510201457.uOrhkKly-lkp@intel.com/

smatch warnings:
drivers/leds/rgb/leds-group-virtualcolor.c:303 parse_monochromatic_leds() warn: 'mono_count' unsigned <= 0
drivers/leds/rgb/leds-group-virtualcolor.c:303 parse_monochromatic_leds() warn: error code type promoted to positive: 'mono_count'

vim +/mono_count +303 drivers/leds/rgb/leds-group-virtualcolor.c

bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 296 static int parse_monochromatic_leds(struct device *dev, struct device_node *child,
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 297 struct virtual_led *vled)
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 298 {
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 299 u32 mono_count;

This needs to be an int.

bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 300 int ret, i;
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 301
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 302 mono_count = of_property_count_elems_of_size(child, "leds", sizeof(u32));
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 @303 if (mono_count <= 0) {
^^^^^^^^^^^^^^^

bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 304 vled->num_monochromatics = 0;
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 305 return 0;
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 306 }
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 307
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 308 vled->num_monochromatics = mono_count;
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 309 vled->monochromatics = devm_kcalloc(dev, vled->num_monochromatics,
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 310 sizeof(*vled->monochromatics), GFP_KERNEL);
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 311 if (!vled->monochromatics)
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 312 return -ENOMEM;
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 313
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 314 for (i = 0; i < vled->num_monochromatics; i++) {
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 315 struct led_classdev *led_cdev;
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 316
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 317 led_cdev = devm_of_led_get(dev, i);
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 318 if (IS_ERR(led_cdev)) {
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 319 ret = PTR_ERR(led_cdev);
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 320 return dev_err_probe(dev, ret,
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 321 "Failed to get monochromatic LED %d\n", i);
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 322 }
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 323
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 324 vled->monochromatics[i] = led_cdev;
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 325 }
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 326
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 327 return 0;
bc8d39d8adf81b2 Jonathan Brophy 2025-10-19 328 }

--
0-DAY CI Kernel Test Service