From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAEFAC4346E for ; Mon, 21 Sep 2020 14:43:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0718235F8 for ; Mon, 21 Sep 2020 14:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600699437; bh=hlCTEfeCQncgpBOMjD101cTzGYTMWM+Cj52a8KqvpF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1YpJfwJPQN1MG6gbbNwsaekiZLALFI9dHNZ/oCG3ghHlsK2Pel/y5lb/YaZtZjUyG 9gh3NuP2eVpMcJbHe12mvsG2f8BekY9m194VbHzrp7O4IYCDZno3r4q1QcNJXDgg/E 7bbrpSzUcpNtIJDT4Ym306LXy2/yQPd/H7Cj7a+k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbgIUOkg (ORCPT ); Mon, 21 Sep 2020 10:40:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727499AbgIUOkg (ORCPT ); Mon, 21 Sep 2020 10:40:36 -0400 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 DBABB23718; Mon, 21 Sep 2020 14:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600699235; bh=hlCTEfeCQncgpBOMjD101cTzGYTMWM+Cj52a8KqvpF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U8O9W0WTbXKk5tbDZC+Rm7geFkXvURdAtwNzJ02go78CprNUhXBicFKk7Fp7ZO5An lkRM8M5RvS4j4KRvoX+m1O5y0nMlCX1O7Jcu7m7mUpUDYmT/hFsqN42W6MmLA9LpBU 8u/wqTTpLup1E8wY6LufG4bw0ga93+RGVhTqp6T0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sumera Priyadarsini , Linus Walleij , Stephen Boyd , Sasha Levin , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 06/20] clk: versatile: Add of_node_put() before return statement Date: Mon, 21 Sep 2020 10:40:13 -0400 Message-Id: <20200921144027.2135390-6-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200921144027.2135390-1-sashal@kernel.org> References: <20200921144027.2135390-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org From: Sumera Priyadarsini [ Upstream commit da9c43dc0e2ec5c42a3d414e389feb30467000e2 ] Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak. Fix a potential memory leak in clk-impd1.c by inserting of_node_put() before a return statement. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini Link: https://lore.kernel.org/r/20200829175704.GA10998@Kaladin Reviewed-by: Linus Walleij Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/versatile/clk-impd1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/versatile/clk-impd1.c b/drivers/clk/versatile/clk-impd1.c index ca798249544d0..85c395df9c008 100644 --- a/drivers/clk/versatile/clk-impd1.c +++ b/drivers/clk/versatile/clk-impd1.c @@ -109,8 +109,10 @@ static int integrator_impd1_clk_probe(struct platform_device *pdev) for_each_available_child_of_node(np, child) { ret = integrator_impd1_clk_spawn(dev, np, child); - if (ret) + if (ret) { + of_node_put(child); break; + } } return ret; -- 2.25.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C567FC43466 for ; Mon, 21 Sep 2020 14:45:23 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 512602076E for ; Mon, 21 Sep 2020 14:45:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0b5GdqoC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QZbEtYfe"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="U8O9W0WT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 512602076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+6RUgjzJNRLsSeYZ07e1xFjE/syEmprJC3hbYgZlrRY=; b=0b5GdqoCP6oLPQuvtgVLaLhY/ U0GgiX+hHLV34rZC5lfQaVPPOI8kK1DdXcNBMN2kZsZmVKQz+ybs5CdAgnoBD+deGQFoD1Y6pj1lT sfJm6ffuCeB3vui9vQPPi4Dw2pqZsG4CttOOuAjSQqg4ZsWWzGMk/wAxm5gRm+c+ljg7JzRJCFCOm ZEb7HqL62cLBrcJX92Av8B38/oqMj3Frr0xeZhqTO3fGrWOiZqrxlFFL3hJFDkaoK6AX1XhhBU3MB asU0Luy5gKW4gF1IzvOiFhgJSIweGcLqV73n6EulSnQ0GxdQqP3RoLpSX9OQuipZQ134mcPsehi6N 5qmcJJDqw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKN2K-00071g-MT; Mon, 21 Sep 2020 14:43:24 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKMzl-0005kF-Mr for linux-arm-kernel@merlin.infradead.org; Mon, 21 Sep 2020 14:40:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=lY8MouDjmMbB7uVWM6EHAy39XzZK0FOj3ckJO4jhY70=; b=QZbEtYfetkkSSfk5PBbVE4q85G x+Box7l8LitneJLi0d/PA2BK+87U9PZrvB4mmj+DM1IHboI2hgYYsbSpedecaISzcFnZrSBbA+ca/ LaveE/ev3EL78wUnUh2lHB9nnNmrA/voyqkRx2a+kf0sudg9cmgOwXEw9Rm5Fq8GgJ53wX+S6Gzho ed7JRKJZcRocN8XcxCAk8vv+87LX3z87DCywsdq9+/j5WyNTGziEliAPnil2b6+/zPCujIsf/ssP1 uyZm9bYp4wDlyYfAk4oAPuAXxCkJ4Kyuiu5F+Lmk7vkCZTtbkPSPoSnj5QscTYXwbga1c6R578DKZ sGMhWGHQ==; Received: from mail.kernel.org ([198.145.29.99]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKMzg-0000NC-9N for linux-arm-kernel@lists.infradead.org; Mon, 21 Sep 2020 14:40:44 +0000 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 DBABB23718; Mon, 21 Sep 2020 14:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600699235; bh=hlCTEfeCQncgpBOMjD101cTzGYTMWM+Cj52a8KqvpF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U8O9W0WTbXKk5tbDZC+Rm7geFkXvURdAtwNzJ02go78CprNUhXBicFKk7Fp7ZO5An lkRM8M5RvS4j4KRvoX+m1O5y0nMlCX1O7Jcu7m7mUpUDYmT/hFsqN42W6MmLA9LpBU 8u/wqTTpLup1E8wY6LufG4bw0ga93+RGVhTqp6T0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 06/20] clk: versatile: Add of_node_put() before return statement Date: Mon, 21 Sep 2020 10:40:13 -0400 Message-Id: <20200921144027.2135390-6-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200921144027.2135390-1-sashal@kernel.org> References: <20200921144027.2135390-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_154040_723066_B9A4E390 X-CRM114-Status: GOOD ( 14.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Sumera Priyadarsini , Stephen Boyd , Linus Walleij , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Sumera Priyadarsini [ Upstream commit da9c43dc0e2ec5c42a3d414e389feb30467000e2 ] Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak. Fix a potential memory leak in clk-impd1.c by inserting of_node_put() before a return statement. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini Link: https://lore.kernel.org/r/20200829175704.GA10998@Kaladin Reviewed-by: Linus Walleij Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/versatile/clk-impd1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/versatile/clk-impd1.c b/drivers/clk/versatile/clk-impd1.c index ca798249544d0..85c395df9c008 100644 --- a/drivers/clk/versatile/clk-impd1.c +++ b/drivers/clk/versatile/clk-impd1.c @@ -109,8 +109,10 @@ static int integrator_impd1_clk_probe(struct platform_device *pdev) for_each_available_child_of_node(np, child) { ret = integrator_impd1_clk_spawn(dev, np, child); - if (ret) + if (ret) { + of_node_put(child); break; + } } return ret; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel