Commit b8a533f3 authored by Nuno Sá's avatar Nuno Sá Committed by Jonathan Cameron
Browse files

iio: ad7292: Fix of_node refcounting



When returning or breaking early from a
`for_each_available_child_of_node()` loop, we need to explicitly call
`of_node_put()` on the child node to possibly release the node.

Fixes: 506d2e31 ("iio: adc: Add driver support for AD7292")
Signed-off-by: default avatarNuno Sá <nuno.sa@analog.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200925091045.302-2-nuno.sa@analog.com


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent b07c47bf
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -310,9 +310,11 @@ static int ad7292_probe(struct spi_device *spi)

	for_each_available_child_of_node(spi->dev.of_node, child) {
		diff_channels = of_property_read_bool(child, "diff-channels");
		if (diff_channels)
		if (diff_channels) {
			of_node_put(child);
			break;
		}
	}

	if (diff_channels) {
		indio_dev->num_channels = ARRAY_SIZE(ad7292_channels_diff);