Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3474001imu; Sun, 11 Nov 2018 15:56:21 -0800 (PST) X-Google-Smtp-Source: AJdET5c3d+8JjRHEX9HNB0nzOcOZLArxJ6ma3AtYRMIXD5QMnLRX/SaBuqLynA0j4MkeJsngf++m X-Received: by 2002:a17:902:bb86:: with SMTP id m6mr476377pls.315.1541980580964; Sun, 11 Nov 2018 15:56:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980580; cv=none; d=google.com; s=arc-20160816; b=crPiqsggzNp7eJa1hqd1xu4nYdtNwUuVJo1DSXqEjCAgrHPi4xX8ona5lAiivACpd9 GhU9niRetI3uI2NC51Q50UcvjKXQ03CUOZePwBrDzw000yf/0rCXRjNy7JedU3X3lqX3 JjqaE0Yu0XIsJFhXwbQFHippqri0MUFaalXXyoBqKvOfdxuUYxRTo87xdNPJ95njD8iI doum73D6+pkyROXVrJsr6DVYUK3APjXhAFekbucAgmWasnt6rOsHMWbzecSMquTZzqMd svAHZ+Z3n/VwpD0DQl9gqjEY+KVsCtd7VA9lxh8RWF6XJNE5B2+Ahx3liPd0BxYVaB/h qq2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zAEaREarOlqlz2cZUjzsN788r70UJO7BEZFjIlFWB2U=; b=Qx9N4UyNMpRbcJnvq/2NR8eY2O8ZQjsCYn/Neh6ptNLQ4zF0dUipSw9FFuiLUZJisM SLPNgKmzRQfcBgjOyip6LU21xzzk4vfDajAJHB2G37GSdv6ev9zOsj4PBD6W+aIJ1i8w wdk03iJQKZJIqB9oFoYUua/sEZ5qOEx0Zs2lt1b63zqv2q11Xp09ceb7G87UsbWbFChJ avD41EMpxlU7uDEF1iDswkctqAfkFLXlrRke1IwzzXk3yqnaVz7t4ojcpc3UMZl2jYdZ rzwhaM4MRn0ocjLpYrqKiaLdH+iErpfiE/PuzYgn1dW9Ibp+1t81Vv6BOZh8LD77Z1SH rCrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1tHAb0NJ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t74si3862418pgc.150.2018.11.11.15.56.05; Sun, 11 Nov 2018 15:56:20 -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=1tHAb0NJ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732629AbeKLISQ (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:35400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732596AbeKLISP (ORCPT ); Mon, 12 Nov 2018 03:18:15 -0500 Received: from localhost (unknown [206.108.79.134]) (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 E784E21582; Sun, 11 Nov 2018 22:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975300; bh=tCn7i+sZkyQlvSoPJmuvqU1gh2SfjuFBiVdlhC5TSiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1tHAb0NJPVMrzerL4mCidK0B9J0lQGFLTzcr6sGAEwirN3ru31Q03T1solGSwsEkm 5av+wLeldHI5EFaosL32Pl4qmSZ5GKCGV2kYjCvFkTAUYyCkBMGcIK7uK/jMPk5jjy PM/JxFcqmPhOZHDZdeyyq4zh2xovHp4rLoc8TlcE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Khoroshilov , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 4.19 259/361] iio: adc: imx25-gcq: Fix leak of device_node in mx25_gcq_setup_cfgs() Date: Sun, 11 Nov 2018 14:20:06 -0800 Message-Id: <20181111221653.827531868@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexey Khoroshilov commit d3fa21c73c391975488818b085b894c2980ea052 upstream. 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: Greg Kroah-Hartman --- drivers/iio/adc/fsl-imx25-gcq.c | 6 ++++++ 1 file changed, 6 insertions(+) --- 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 pl 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 pl 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 pl 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 pl 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; }