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

iio: adc: qcom-spmi-vadc: use scoped device_for_each_child_node()

Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error path.

This prevents possible memory leaks if new error paths are added without
the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240926-iio_device_for_each_child_node_scoped-v1-2-64ca8a424578@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Javier Carrasco and committed by
Jonathan Cameron
140eff34 db44b37a

+2 -5
+2 -5
drivers/iio/adc/qcom-spmi-vadc.c
··· 754 754 const struct vadc_channels *vadc_chan; 755 755 struct iio_chan_spec *iio_chan; 756 756 struct vadc_channel_prop prop; 757 - struct fwnode_handle *child; 758 757 unsigned int index = 0; 759 758 int ret; 760 759 ··· 773 774 774 775 iio_chan = vadc->iio_chans; 775 776 776 - device_for_each_child_node(vadc->dev, child) { 777 + device_for_each_child_node_scoped(vadc->dev, child) { 777 778 ret = vadc_get_fw_channel_data(vadc->dev, &prop, child); 778 - if (ret) { 779 - fwnode_handle_put(child); 779 + if (ret) 780 780 return ret; 781 - } 782 781 783 782 prop.scale_fn_type = vadc_chans[prop.channel].scale_fn_type; 784 783 vadc->chan_props[index] = prop;