Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be negative

The variable 'count' is defined as unsigned type, so the following if
statement is invalid, we can modify the type of count to int.

if (count <= 0) {
dev_err(dev, "No led-sources specified\n");
return -ENODEV;
}

./drivers/leds/flash/leds-qcom-flash.c:546:5-10: WARNING: Unsigned expression compared with zero: count <= 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5344
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230531053559.5702-1-jiapeng.chong@linux.alibaba.com

authored by

Jiapeng Chong and committed by
Lee Jones
b3f4b679 dda96847

+2 -2
+2 -2
drivers/leds/flash/leds-qcom-flash.c
··· 538 538 struct led_init_data init_data; 539 539 struct led_classdev_flash *flash = &led->flash; 540 540 struct led_flash_setting *brightness, *timeout; 541 - u32 count, current_ua, timeout_us; 541 + u32 current_ua, timeout_us; 542 542 u32 channels[4]; 543 - int i, rc; 543 + int i, rc, count; 544 544 545 545 count = fwnode_property_count_u32(node, "led-sources"); 546 546 if (count <= 0) {