Re: [PATCH v2 4/4] leds: Add Virtual Color LED Group driver

From: Dan Carpenter

Date: Thu Oct 23 2025 - 10:48:10 EST


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-leds-Add-YAML-bindings-for-Virtual-Color-LED-Group-driver/20251013-201353
base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next
patch link: https://lore.kernel.org/r/20251013120955.227572-5-professorjonny98%40gmail.com
patch subject: [PATCH v2 4/4] leds: Add Virtual Color LED Group driver
config: loongarch-randconfig-r072-20251019 (https://download.01.org/0day-ci/archive/20251023/202510231653.3V9E5oxE-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 15.1.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@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202510231653.3V9E5oxE-lkp@xxxxxxxxx/

smatch warnings:
drivers/leds/rgb/leds-group-virtualcolor.c:239 leds_virtualcolor_init_vled() warn: 'phandle_count' unsigned <= 0

vim +/phandle_count +239 drivers/leds/rgb/leds-group-virtualcolor.c

793ec9b4ba92eea Jonathan Brophy 2025-10-14 218 static int leds_virtualcolor_init_vled(struct device *dev, struct device_node *child,
793ec9b4ba92eea Jonathan Brophy 2025-10-14 219 struct virtual_led *vled, struct leds_virtualcolor *vc_data)
793ec9b4ba92eea Jonathan Brophy 2025-10-14 220 {
793ec9b4ba92eea Jonathan Brophy 2025-10-14 221 struct led_init_data init_data = {};
793ec9b4ba92eea Jonathan Brophy 2025-10-14 222 u32 blink_interval;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 223 u32 phandle_count;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 224 u32 max_brightness;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 225 int ret;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 226 int i;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 227
793ec9b4ba92eea Jonathan Brophy 2025-10-14 228 ret = of_property_read_u32(child, "priority", &vled->priority);
793ec9b4ba92eea Jonathan Brophy 2025-10-14 229 if (ret)
793ec9b4ba92eea Jonathan Brophy 2025-10-14 230 vled->priority = 0;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 231
793ec9b4ba92eea Jonathan Brophy 2025-10-14 232 ret = of_property_read_u32(child, "blink", &blink_interval);
793ec9b4ba92eea Jonathan Brophy 2025-10-14 233 if (!ret) {
793ec9b4ba92eea Jonathan Brophy 2025-10-14 234 vled->blink_delay_on = blink_interval;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 235 vled->blink_delay_off = blink_interval;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 236 }
793ec9b4ba92eea Jonathan Brophy 2025-10-14 237
793ec9b4ba92eea Jonathan Brophy 2025-10-14 238 phandle_count = of_property_count_elems_of_size(child, "leds", sizeof(u32));
793ec9b4ba92eea Jonathan Brophy 2025-10-14 @239 if (phandle_count <= 0) {
^^^^^^^^^^^^^^^^^^
u32 can't be < 0.

793ec9b4ba92eea Jonathan Brophy 2025-10-14 240 dev_err(dev, "No monochromatic LEDs specified for virtual LED %s\n",
793ec9b4ba92eea Jonathan Brophy 2025-10-14 241 vled->cdev.name);
793ec9b4ba92eea Jonathan Brophy 2025-10-14 242 return -EINVAL;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 243 }
793ec9b4ba92eea Jonathan Brophy 2025-10-14 244
793ec9b4ba92eea Jonathan Brophy 2025-10-14 245 vled->num_monochromatics = phandle_count;
793ec9b4ba92eea Jonathan Brophy 2025-10-14 246 vled->monochromatics = devm_kcalloc(dev, vled->num_monochromatics,
793ec9b4ba92eea Jonathan Brophy 2025-10-14 247 sizeof(*vled->monochromatics), GFP_KERNEL);
793ec9b4ba92eea Jonathan Brophy 2025-10-14 248 if (!vled->monochromatics)
793ec9b4ba92eea Jonathan Brophy 2025-10-14 249 return -ENOMEM;

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki