mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 09:13:38 +00:00
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>
This commit is contained in:
parent
db44b37a20
commit
140eff34e1
@ -754,7 +754,6 @@ static int vadc_get_fw_data(struct vadc_priv *vadc)
|
||||
const struct vadc_channels *vadc_chan;
|
||||
struct iio_chan_spec *iio_chan;
|
||||
struct vadc_channel_prop prop;
|
||||
struct fwnode_handle *child;
|
||||
unsigned int index = 0;
|
||||
int ret;
|
||||
|
||||
@ -774,12 +773,10 @@ static int vadc_get_fw_data(struct vadc_priv *vadc)
|
||||
|
||||
iio_chan = vadc->iio_chans;
|
||||
|
||||
device_for_each_child_node(vadc->dev, child) {
|
||||
device_for_each_child_node_scoped(vadc->dev, child) {
|
||||
ret = vadc_get_fw_channel_data(vadc->dev, &prop, child);
|
||||
if (ret) {
|
||||
fwnode_handle_put(child);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
prop.scale_fn_type = vadc_chans[prop.channel].scale_fn_type;
|
||||
vadc->chan_props[index] = prop;
|
||||
|
Loading…
Reference in New Issue
Block a user