Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1777496imd; Sun, 4 Nov 2018 09:13:52 -0800 (PST) X-Google-Smtp-Source: AJdET5e2Jc/7EGZh7cWtaR0j6R71jR2U/hXNVBXPJtUDBHKGcACOSDhOZudlxR41A1kCZ58iRI1J X-Received: by 2002:a17:902:16a4:: with SMTP id h33-v6mr18941649plh.141.1541351632147; Sun, 04 Nov 2018 09:13:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541351632; cv=none; d=google.com; s=arc-20160816; b=w+WDToKYiQnRv33La7npi99jLkvNz4qQumP9pjfVWrYAsK3DBQiBy2Cyei7Cq2eoAz Kc+bQWH6dysbiQETLO4Sd4EikhBU+KuoLV2YcI0iWJWmFYjNx2hPYaRAsHf72wr5e1Mb JP+6Wz640jhMMm0lZbr5ADdX2V6yiM4aQGunzZrW1B9YYzjRtLqymQkqp9rjXNqSNIFg AjGLzrLT+DHWwb3CgfoZwlyXQrfiNqjq+Xu/Ln0tynYh5kLgE/gnRix1/Ev5EJZk3A9+ 6/snZi8L6i1uGuki5BPobfLJlBO0kFhQKkNXG5oJ1SzpURILzTq3S0sY4B26cjyqnmQs 91bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=3utkiu+5RdN3VDAG6WhoFfjogt6pE+gmT2NkRC0bVQQ=; b=c9+PtRrko5q7475/K1aMMzkVxJfY6qHc0Gqu342Qs7ztExUeWldRTucI2Mtf9JPSD3 OxoURdvyYmk8M4jBycN75t86RuFjCVjQowKtQztpp0Rt8xueC+fS54yy4F6je41CQZ4/ 53lkZnvk77WewGuL68BRE+qu+P0WGyMJQmzazMaz5X0mT1wBRTbdQY5d+LIPnas+b+5l MWgbreVply6mdBQyb5da2UQoDKwuPd9UUEb6bkhEbSzSb1kZHbgbAVwp3/yBRPT6vwEv v+86thVPQkl9ZWexxOm9yUSiNO/6LrVv7kDLiav7OHH4Fy6gNx4ZLgknN+uveC9f8tqz 2eSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=upiL+8at; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id b68-v6si30251497pfe.168.2018.11.04.09.13.04; Sun, 04 Nov 2018 09:13:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=upiL+8at; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1731349AbeKDXIw (ORCPT + 99 others); Sun, 4 Nov 2018 18:08:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:47946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728896AbeKDXIu (ORCPT ); Sun, 4 Nov 2018 18:08:50 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 506EC20870; Sun, 4 Nov 2018 13:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339626; bh=I+9mpVB2hiqVIS9/V1kkHxylATbjP0qUHJjvL2B/H9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=upiL+8at9Js83KmrHezDcaiQqeYB+movBxGzoqFx7kvAGe5LRCZQX6D4eqkHIUfZL +damQs8e7WU5PKqImEJO2lZ+Ejyz6RNN7oeH3/GCDJ+e6XIjbfBqCrMe3QQcNJ6dsH 6PPcg6VfHp5g1iYY3VbxbLTvIctUrVNDdFvM8SPk= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexey Khoroshilov , Stable@vger.kernel.org, Jonathan Cameron , Sasha Levin Subject: [PATCH AUTOSEL 4.14 20/30] iio: adc: imx25-gcq: Fix leak of device_node in mx25_gcq_setup_cfgs() Date: Sun, 4 Nov 2018 08:53:15 -0500 Message-Id: <20181104135325.88524-20-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexey Khoroshilov [ Upstream commit d3fa21c73c391975488818b085b894c2980ea052 ] Leaving for_each_child_of_node loop we should release child device node, if it is not stored for future use. Found by Linux Driver Verification project (linuxtesting.org). JC: I'm not sending this as a quick fix as it's been wrong for years, but good to pick up for stable after the merge window. Signed-off-by: Alexey Khoroshilov Fixes: 6df2e98c3ea56 ("iio: adc: Add imx25-gcq ADC driver") Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/fsl-imx25-gcq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c index ea264fa9e567..929c617db364 100644 --- a/drivers/iio/adc/fsl-imx25-gcq.c +++ b/drivers/iio/adc/fsl-imx25-gcq.c @@ -209,12 +209,14 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, ret = of_property_read_u32(child, "reg", ®); if (ret) { dev_err(dev, "Failed to get reg property\n"); + of_node_put(child); return ret; } if (reg >= MX25_NUM_CFGS) { dev_err(dev, "reg value is greater than the number of available configuration registers\n"); + of_node_put(child); return -EINVAL; } @@ -228,6 +230,7 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, if (IS_ERR(priv->vref[refp])) { dev_err(dev, "Error, trying to use external voltage reference without a vref-%s regulator.", mx25_gcq_refp_names[refp]); + of_node_put(child); return PTR_ERR(priv->vref[refp]); } priv->channel_vref_mv[reg] = @@ -240,6 +243,7 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, break; default: dev_err(dev, "Invalid positive reference %d\n", refp); + of_node_put(child); return -EINVAL; } @@ -254,10 +258,12 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, if ((refp & MX25_ADCQ_CFG_REFP_MASK) != refp) { dev_err(dev, "Invalid fsl,adc-refp property value\n"); + of_node_put(child); return -EINVAL; } if ((refn & MX25_ADCQ_CFG_REFN_MASK) != refn) { dev_err(dev, "Invalid fsl,adc-refn property value\n"); + of_node_put(child); return -EINVAL; } -- 2.17.1