]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
iio: ad7292: Fix of_node refcounting
authorNuno Sá <nuno.sa@analog.com>
Fri, 25 Sep 2020 09:10:45 +0000 (11:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:51:42 +0000 (11:51 +0100)
commit b8a533f3c24b3b8f1fdbefc5ada6a7d5733d63e6 upstream.

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: 506d2e317a0a0 ("iio: adc: Add driver support for AD7292")
Signed-off-by: Nuno 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: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/ad7292.c

index 2eafbe7ac7c7bef6bdffa28a6fa4feb86a2c6d83..ab204e9199e99e3678ee5fcca47512bc84487219 100644 (file)
@@ -310,8 +310,10 @@ 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) {