Skip to content

Commit

Permalink
iio: adc: rzg2l_adc: add missing fwnode_handle_put() in rzg2l_adc_par…
Browse files Browse the repository at this point in the history
…se_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: d484c21 ("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>
  • Loading branch information
Jialin Zhang authored and Jonathan Cameron committed Jun 19, 2022
1 parent 7860172 commit d836715
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/iio/adc/rzg2l_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,15 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l
i = 0;
device_for_each_child_node(&pdev->dev, fwnode) {
ret = fwnode_property_read_u32(fwnode, "reg", &channel);
if (ret)
if (ret) {
fwnode_handle_put(fwnode);
return ret;
}

if (channel >= RZG2L_ADC_MAX_CHANNELS)
if (channel >= RZG2L_ADC_MAX_CHANNELS) {
fwnode_handle_put(fwnode);
return -EINVAL;
}

chan_array[i].type = IIO_VOLTAGE;
chan_array[i].indexed = 1;
Expand Down

0 comments on commit d836715

Please sign in to comment.