Skip to content

Commit

Permalink
iio: adc: ti-ads131e08: add missing fwnode_handle_put() in ads131e08_…
Browse files Browse the repository at this point in the history
…alloc_channels()

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: d935edd ("iio: adc: Add driver for Texas Instruments ADS131E0x ADC family")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com>
Link: https://lore.kernel.org/r/20220517033020.2033324-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 d836715 commit 47dcf77
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/iio/adc/ti-ads131e08.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,15 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
device_for_each_child_node(dev, node) {
ret = fwnode_property_read_u32(node, "reg", &channel);
if (ret)
return ret;
goto err_child_out;

ret = fwnode_property_read_u32(node, "ti,gain", &tmp);
if (ret) {
channel_config[i].pga_gain = ADS131E08_DEFAULT_PGA_GAIN;
} else {
ret = ads131e08_pga_gain_to_field_value(st, tmp);
if (ret < 0)
return ret;
goto err_child_out;

channel_config[i].pga_gain = tmp;
}
Expand All @@ -758,7 +758,7 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
} else {
ret = ads131e08_validate_channel_mux(st, tmp);
if (ret)
return ret;
goto err_child_out;

channel_config[i].mux = tmp;
}
Expand All @@ -784,6 +784,10 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
st->channel_config = channel_config;

return 0;

err_child_out:
fwnode_handle_put(node);
return ret;
}

static void ads131e08_regulator_disable(void *data)
Expand Down

0 comments on commit 47dcf77

Please sign in to comment.