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

generic-adc-battery: Fix checking if none of the channels are supported

If none of the channels are supported, index is 0. Also ensure to return
error code instead of 0 in goto second_mem_fail path.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: anish kumar <anish198519851985@gmail.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>

authored by

Axel Lin and committed by
Anton Vorontsov
d211c6e8 e0835879

+3 -1
+3 -1
drivers/power/generic-adc-battery.c
··· 299 299 } 300 300 301 301 /* none of the channels are supported so let's bail out */ 302 - if (index == ARRAY_SIZE(gab_chan_name)) 302 + if (index == 0) { 303 + ret = -ENODEV; 303 304 goto second_mem_fail; 305 + } 304 306 305 307 /* 306 308 * Total number of properties is equal to static properties