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

iio: adc: rzg2l_adc: add missing fwnode_handle_put() in rzg2l_adc_parse_properties()

fwnode_handle_put() should be used when terminating
device_for_each_child_node() iteration with break or return to prevent
stale device node references from being left behind.

Fixes: d484c21bacfa ("iio: adc: Add driver for Renesas RZ/G2L A/D converter")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20220517033526.2035735-1-zhangjialin11@huawei.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Jialin Zhang and committed by
Jonathan Cameron
d836715f 78601726

+6 -2
+6 -2
drivers/iio/adc/rzg2l_adc.c
··· 334 334 i = 0; 335 335 device_for_each_child_node(&pdev->dev, fwnode) { 336 336 ret = fwnode_property_read_u32(fwnode, "reg", &channel); 337 - if (ret) 337 + if (ret) { 338 + fwnode_handle_put(fwnode); 338 339 return ret; 340 + } 339 341 340 - if (channel >= RZG2L_ADC_MAX_CHANNELS) 342 + if (channel >= RZG2L_ADC_MAX_CHANNELS) { 343 + fwnode_handle_put(fwnode); 341 344 return -EINVAL; 345 + } 342 346 343 347 chan_array[i].type = IIO_VOLTAGE; 344 348 chan_array[i].indexed = 1;