Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1774029ybh; Sun, 4 Aug 2019 09:21:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqycG8ISOZSm9wVolYDyiBGanopmygwIks0jnpQ1E4+VSk7tQA6VBEQ+3RkDhSBYFXpZi1sN X-Received: by 2002:a62:1b0c:: with SMTP id b12mr68163326pfb.17.1564935690414; Sun, 04 Aug 2019 09:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564935690; cv=none; d=google.com; s=arc-20160816; b=X1O+knajU0B/vS0MpmXekXu6Y6Nionn87JAk1+5dRerENqkb98jJRfyI6f6nyNMPWD 8J6se/1DAUnMg1wR4HTowdBdsQA2ebgXH5oukFyo7sgjlRE43vu0TXi7QgQjT2bvokks uOgR4A+tghmLN/Ja/zzlRCPDNXquPHS4PU3DCvkj6IEtNSM4L0vcDy/5rZWd/4tM/Xcy VpIjFPFYqaEV0buJAGu/KEc64W9hq7ajJQLGKE/NbwWXmkvLvhDFaqPi3eEUak73uf47 r/DvlWRiDRN2NMngBvt3j9stKq5t9pB4Xa82PthT0PV89J8PiJhTjCpe7dyfqZv25zFV 0ybA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=RAhLVv+TDY5bQcYl+NXFjNhU9tR7BPyaRx/k/4DyyF8=; b=wtPFO0gy6Nss4jC0X4U0Zc8bP3b4BQ0RfZbR2lX692Whv5ssxYGUiiXJRtI3Qo9tMm l7x47aix1BGAR/4tPmgVSOwM9cCoZePCu2ukTuuQjsxH69wQ16G1EOm/tEPcmPx4Vm+M eS2P0rj22pBHtuq9s6YF2ebuMMXbASVJcfwDb2GKiAfDpvF/nnBA+z2ImE5k0jsogyLA lLJevcbhXQ/fh1rSje0juZGIQNhnWvpPKYYgBPh+hDjb8WSMQCpgN75WKU1dXTTMyaZ1 EjnpByj2Xt9g4m39fLuBGUwKwsqjCaTy7h3ZBPGE/FVvOWwVCYd2cCP9rgmfnaaD68T5 b8OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=atCXWNlx; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si38178715pfn.38.2019.08.04.09.21.12; Sun, 04 Aug 2019 09:21:30 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=atCXWNlx; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726422AbfHDQUg (ORCPT + 99 others); Sun, 4 Aug 2019 12:20:36 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:43208 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbfHDQUg (ORCPT ); Sun, 4 Aug 2019 12:20:36 -0400 Received: by mail-pf1-f193.google.com with SMTP id i189so38364074pfg.10 for ; Sun, 04 Aug 2019 09:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RAhLVv+TDY5bQcYl+NXFjNhU9tR7BPyaRx/k/4DyyF8=; b=atCXWNlxav1dtL7F4U4MgGLdCrMFihKDTns2PoxBk8cXDIj8Ac6jRKBOZs5RH49KI3 fll83PWrd1eFnpu+jLXwm6ya3gnVTjm8ohFDGJmPLRJQOY4rCiO4bavfyO9F+dokF1MX AdKriPl57Cj1cBCpOCgLzjfOHEEJRgQJgTIzrmTMhlnq/KlLTkRoa3EnwBjZcRz21g0V 2i97pzX7JaM6ebRsy2T3Op+VUuVzO6/78Se6Jf7C8bKZejXa9wBOefXh/IuOIPBuYVcB 6PVR9Cc6WK+GB2f7IVEeBGWTLyWDAJ6tFaroLNDLrAUFQ64hCYAJs7mnXv/o70fhKkYv HUsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RAhLVv+TDY5bQcYl+NXFjNhU9tR7BPyaRx/k/4DyyF8=; b=r9p00FCpb12vw4d8C/nOStX8DKKtyuLE5m0jA9Y/So0p+NCsURzUpJWX2fjbFLr/Ws DLQr80SQozUtJa3KR61lCSGR7VJgKksGFhfm9Mkwe3Ka5elzZCIeZiSIKNIt8WgWf/NW Tdj2/SFVETNfK0tdWS0zBUJDpZCUIKFnu4TouXBzycGVKvSMO4n6Wa2apY1haOvGp11v X+NYquUXYhP/RK9InoL+ypIpVkTO9gfq+o2yYH8+3IMxPSEPFA3c0d8/ihdK64MRb47A jMTrX/lWw9WKZbkh26VkxllMUPr79jVtCIhf3RTlvr9MjtLD4DoyAAQqnIf7XdDQ1bxP SzNA== X-Gm-Message-State: APjAAAW5alJprfw/bUq/0cU9GynviMwFbtoeMVYjUFwbwY5k21M2ntvV rpoQNCPs7ICjjBH13hpOQfg= X-Received: by 2002:a62:f250:: with SMTP id y16mr68836412pfl.50.1564935635868; Sun, 04 Aug 2019 09:20:35 -0700 (PDT) Received: from localhost.localdomain ([122.163.105.8]) by smtp.gmail.com with ESMTPSA id h14sm106731763pfq.22.2019.08.04.09.20.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 04 Aug 2019 09:20:35 -0700 (PDT) From: Nishka Dasgupta To: lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org Cc: Nishka Dasgupta Subject: [PATCH] regulator: core: Add of_node_put() before return Date: Sun, 4 Aug 2019 21:50:23 +0530 Message-Id: <20190804162023.5673-1-nishkadg.linux@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Each iteration of for_each_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return in two places. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta --- drivers/regulator/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index e0c0cf462004..7a5d52948703 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -380,9 +380,12 @@ static struct device_node *of_get_child_regulator(struct device_node *parent, if (!regnode) { regnode = of_get_child_regulator(child, prop_name); - if (regnode) + if (regnode) { + of_node_put(child); return regnode; + } } else { + of_node_put(child); return regnode; } } -- 2.19.1