Skip to contentSkip to conversation

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

PATCH Applied Jialin Zhang 4 participants 4 messages May 17, 2022 – May 22, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/iio/adc/rzg2l_adc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iio/adc/rzg2l_adc.c +6 -2
index 7585144b9715..5b09a93fdf34 100644
@@ -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;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jialin Zhang

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")

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Reviewed-by Lad Prabhakar on v1 1/1
#2 lore raw
In reply to Jialin Zhang
Quoted 6 lines · Jialin Zhang

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.

Quoted 7 lines
Fixes d484c21bacfa ("iio: adc: Add driver for Renesas RZ/G2L A/D converter")
---
 drivers/iio/adc/rzg2l_adc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Cheers,
Prabhakar

Quoted 25 lines
drivers/iio/adc/rzg2l_adc.c +6 -3
index 7585144b9715..5b09a93fdf34 100644
@@ -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;
--

2.25.1

maintainer Applied
#3 lore raw
In reply to Jialin Zhang
Quoted 8 lines · On Tue, 17 May 2022 11:35:26 +0800 Jialin Zhang <[email protected]>…

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")

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

Quoted 26 lines
---
 drivers/iio/adc/rzg2l_adc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iio/adc/rzg2l_adc.c +6 -2
index 7585144b9715..5b09a93fdf34 100644
@@ -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;