Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1867760pxk; Sat, 26 Sep 2020 07:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcGWw8VTDEm3/YizwUUWzQyPcIgRAmNzNj7VH3GJ4XAlpGzgqXv91zpfrIRNci/57ido9o X-Received: by 2002:a17:907:1042:: with SMTP id oy2mr7446358ejb.64.1601131781580; Sat, 26 Sep 2020 07:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601131781; cv=none; d=google.com; s=arc-20160816; b=OZonNI7wRWmIhv3T/OG/fPL34i3i1G3q9ZF1yMzBUHr0h0Kf1aaeG77VsMShBltsgB eoTBg3IyllBLWnX0oLQqofBkdgFQdV71yOdy14kVOvgbE3ixFwldFYlb0AZMnPybOLMM SjxviL4n0PnONZEeU0HxX5ybkaRiRjKD1k4223pBlR4knKKgwq4rGKDIbAXvY4mbesPC bcTh94kFR12LXOgFdjvUk9IFOlRNbnHviddVCGj+HfcNsciHgP9rTlHWZIe7/Z+o33il 0zlj8tzXlpajJiS+Cb2Ohh8a3kmoKqM6LLaC0g1mSsU/1BCR8JeP5WscbGaDTOeYZWN0 cx1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=H1TpOrq+MGNqaHYZD5L7LIFuXrZqwknJEtV7owUc1bM=; b=h96ut8oVPPGKpqHQVa2sZsCpU0W9WcrjriI/PNS5ZtQUBHVYGlVjtEOKse6e059u/D mZDVdrnCJDqFJ/oJtnRNYQo5YKYo7N11ZUEZgaoxz44NrjWCsxjAf4lEH/POTwIwxsbj OmfQuqk9S/s3HOp+MqaruMgZTUxX/bRuYknZvw/3T7X0iqyd7b2Sf2avFWbEzkIElvXg 3dgTQx6Is8UqOVwwodY5uPuCp3kRnJ0S1wDmrEfH0amYkOTlwgOKXwqPlmiSY0dW9ZfP pFpxg96gAv5wBlOMuo/jK3sNR7DTxioTbn4pHhvxN7UD1PYDdIgnNR/MRyiIcjbG6CP/ ftSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZnUVc1pY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si4831410ejd.305.2020.09.26.07.49.18; Sat, 26 Sep 2020 07:49:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZnUVc1pY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729260AbgIZOr4 (ORCPT + 99 others); Sat, 26 Sep 2020 10:47:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:41720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbgIZOr4 (ORCPT ); Sat, 26 Sep 2020 10:47:56 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8860620BED; Sat, 26 Sep 2020 14:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601131675; bh=Cqdr63Eq+wVYenVsZtUQn/PzWYTxrwYKIvL/ax56lK4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZnUVc1pY/DOXxviiOjWmvHX6FXf6dmvD6tX3skZ6P82lnO0tpJ1uAPIoM5QbpAap/ d2tKWYXsW+2xK9pUiJul6AKGUbq2G4BfFNnvd2Yr9jCrJDlrsUUvJNseXFCNQBG/St 3DCrTxxWw4RKNP4M0i9gTu9SwvV6kwHlgi7Uz488= Date: Sat, 26 Sep 2020 15:47:51 +0100 From: Jonathan Cameron To: Tobias Jordan Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Lars-Peter Clausen , Peter Meerwald-Stadler Subject: Re: [PATCH] iio: adc: gyroadc: fix leak of device node iterator Message-ID: <20200926154751.0bfd072f@archlinux> In-Reply-To: <20200926104515.GA12079@agrajag.zerfleddert.de> References: <20200926104515.GA12079@agrajag.zerfleddert.de> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 26 Sep 2020 12:45:15 +0200 Tobias Jordan wrote: > Add missing of_node_put calls for the error paths of the > for_each_child_of_node loop in rcar_gyroadc_parse_subdevs. > > Thought about adding an "goto err_of_node_put" instead, but as the error > paths are quite divergent, I'm not sure if that wouldn't complicate > things. > > Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver") > Signed-off-by: Tobias Jordan Looks to me like there is one more route out of the for_each_child_of_node() that this doesn't cover. if (childmode == RCAR_GYROADC_MODE_SELECT_1_MB88101A) break; If you agree, could you add an of_put_node() to that as well. It's not an error path, but it does break out early. Probably also want to modify the description of the patch a tiny bit to match with that changing being in there as well. Thanks, Jonathan > --- > drivers/iio/adc/rcar-gyroadc.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c > index dcaefc108ff6..3746b0276b80 100644 > --- a/drivers/iio/adc/rcar-gyroadc.c > +++ b/drivers/iio/adc/rcar-gyroadc.c > @@ -357,6 +357,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) > num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3); > break; > default: > + of_node_put(child); > return -EINVAL; > } > > @@ -374,6 +375,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) > dev_err(dev, > "Failed to get child reg property of ADC \"%pOFn\".\n", > child); > + of_node_put(child); > return ret; > } > > @@ -382,6 +384,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) > dev_err(dev, > "Only %i channels supported with %pOFn, but reg = <%i>.\n", > num_channels, child, reg); > + of_node_put(child); > return -EINVAL; > } > } > @@ -391,6 +394,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) > dev_err(dev, > "Channel %i uses different ADC mode than the rest.\n", > reg); > + of_node_put(child); > return -EINVAL; > } > > @@ -401,6 +405,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) > if (IS_ERR(vref)) { > dev_dbg(dev, "Channel %i 'vref' supply not connected.\n", > reg); > + of_node_put(child); > return PTR_ERR(vref); > } >