Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2933457ybh; Mon, 5 Aug 2019 09:11:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEfLwKJ++0GFHzLX67wHpIlZrFi5AuMwRT6B/0sZ4lC1RUvuKfx3hSCKbBY59NpCz5ysSf X-Received: by 2002:a63:5765:: with SMTP id h37mr103165610pgm.183.1565021460391; Mon, 05 Aug 2019 09:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565021460; cv=none; d=google.com; s=arc-20160816; b=bUlRitTcLHLo66rkGw0Wvjrx0O0vgIqtRgiv4buuxkxo4v1t9PSFFB8hpNwgihz+NY QLqG0jxFzGDjDH3t7J4pDbKZZqGwuKMur2bETeA7s7HLqXUBP0R6nX335ApasRNoqNL5 Objsi3bU+GJAsfnn1JLS2IJeo3wCbMPZfuf2LdnqbjI+Vq2MHtER5S9HW0wRxzVZeFHH Cv+taQpQdImeEnzpv0yey+DxuJAaOvxQdyG/ECv3lvp2LRlr0/uQQZkpb7Jz/5l96g56 DNRk4S9HmHCczHxfhayZZDsG1bZm/mZ8oPHAdaUO8aeyMhG+pAaC/+zdopkuzxpxqa43 oMMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature; bh=7Uxl0ZKm2A/r9ieAhBWOkTy1zwF3j76as57EGlYyu9I=; b=m+avHA1OC5i1ipM1X+7qQ+PChULn6gFWRglcXlSCTcx8by/2m5zLay9f+6cZEU4PJM GCWGXlM18gkFLPnN2U5FU3BFFPWi5ne2GkgPEeWqKuBPS77qEdJPMJEcoC1nL6JHBqGy vKB2kOX2hWVJs356gMunXiMXzwWh5iI98UINmuasb8UcW8OZu71EnPJ19CsZwU9N50ll S9b5YO+UJvmuNgILrOGO0YQRRTfFZHWtGGg/FKNBGKc6BFVD0Nt3Eshh6JdnOZ4KdXJf nVhADRyp8ssJPNcUM/TSY0Qb9jTH/5ck69X89b9lrmfIHi086Q8zOVgRBy87Sx04obrC 1f7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=D6f5etZH; 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=fail (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 t129si49461801pfb.16.2019.08.05.09.10.44; Mon, 05 Aug 2019 09:11:00 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=D6f5etZH; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728970AbfHEQKL (ORCPT + 99 others); Mon, 5 Aug 2019 12:10:11 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:37146 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728760AbfHEQKK (ORCPT ); Mon, 5 Aug 2019 12:10:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=7Uxl0ZKm2A/r9ieAhBWOkTy1zwF3j76as57EGlYyu9I=; b=D6f5etZHZXU1 ZcIVVhu/b6t5MSuZ4+AZpde1JnryV+eEaiF3OkgQ4VnPyc6qJnaeVm3jhBBzqC9Q0QOAxeFmEnaK8 gSPZAu8+fpRu9edk9I3xNF/N89Q2GnvxnCrRuaeV0+b3OzNsrNeH9q1OepEISYF/jvdw9Aw7O3U4u TQUn8=; Received: from ypsilon.sirena.org.uk ([2001:470:1f1d:6b5::7]) by heliosphere.sirena.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hufYm-0000n0-Di; Mon, 05 Aug 2019 16:10:08 +0000 Received: by ypsilon.sirena.org.uk (Postfix, from userid 1000) id C232B2742D06; Mon, 5 Aug 2019 17:10:07 +0100 (BST) From: Mark Brown To: Nishka Dasgupta Cc: broonie@kernel.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, Mark Brown Subject: Applied "regulator: core: Add of_node_put() before return" to the regulator tree In-Reply-To: <20190804162023.5673-1-nishkadg.linux@gmail.com> X-Patchwork-Hint: ignore Message-Id: <20190805161007.C232B2742D06@ypsilon.sirena.org.uk> Date: Mon, 5 Aug 2019 17:10:07 +0100 (BST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regulator: core: Add of_node_put() before return has been applied to the regulator tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.4 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From db2a17320a25a63b46ddb081a306af9ded1b906e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Sun, 4 Aug 2019 21:50:23 +0530 Subject: [PATCH] regulator: core: Add of_node_put() before return 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 Link: https://lore.kernel.org/r/20190804162023.5673-1-nishkadg.linux@gmail.com Signed-off-by: Mark Brown --- 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.20.1