From patchwork Wed Jul 19 16:57:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 9852855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F91E602BD for ; Wed, 19 Jul 2017 16:57:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DD9F2861F for ; Wed, 19 Jul 2017 16:57:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 826142869A; Wed, 19 Jul 2017 16:57:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 122092861F for ; Wed, 19 Jul 2017 16:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=5j3ehq+kNbwH3Sy3RBSKerTYK4p+6iRZCYNiTJioZ3I=; b=Mpz9SK4tmyuvtM 7v2WTK0YD35a6AwogVkbF+hKpIA+JDaXMG0Y0IQAIzmyFfEo8B2dk5fRVhUubw4ba5X4KlvNVqHVr 18wq7M8Foxi+nvb51/lx4p6oufJGEO2kBbjfMuY/WZcunGV0ARCRXP8qBcH6PBhwJOMXtnozwAiA8 vPbz1dAbmimlQiNZvg+0hTlWkT68h0z/sqO1AvNQH6uMRO0oD0gpCGjvU791AtndiMo5VZq+QvhAe mWRs5VFXaBs2cIt8ihK1IRpU0UXjOzKP/GASNPcfdcDFQ5WEVvXfsOvrvkDZD/ewBtF3hhQotv9jA 0YMe9yawVVJ48TBqPYJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dXsI4-000592-B3; Wed, 19 Jul 2017 16:57:36 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dXsI0-00057H-Ty for linux-arm-kernel@lists.infradead.org; Wed, 19 Jul 2017 16:57:34 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dXsHX-0004ge-2S; Wed, 19 Jul 2017 16:57:03 +0000 From: Colin King To: Alessandro Zummo , Alexandre Belloni , Maxime Ripard , Chen-Yu Tsai , linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] rtc: sun6i: ensure clk_data is kfree'd on error Date: Wed, 19 Jul 2017 17:57:02 +0100 Message-Id: <20170719165702.22220-1-colin.king@canonical.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170719_095733_175712_CC1B1C46 X-CRM114-Status: GOOD ( 10.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King There are two error return paths that do not kfree clk_data and we end up with a memory leak. Fix these with a kfree error exit path. Detected by CoverityScan, CID#1402959 ("Resource Leak") Signed-off-by: Colin Ian King --- drivers/rtc/rtc-sun6i.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index 39cbc1238b92..61502221ab6e 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -204,7 +204,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node) rtc->base = of_io_request_and_map(node, 0, of_node_full_name(node)); if (IS_ERR(rtc->base)) { pr_crit("Can't map RTC registers"); - return; + goto err; } /* Switch to the external, more precise, oscillator */ @@ -216,7 +216,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node) /* Deal with old DTs */ if (!of_get_property(node, "clocks", NULL)) - return; + goto err; rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL, "rtc-int-osc", @@ -246,6 +246,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node) clk_data->num = 1; clk_data->hws[0] = &rtc->hw; of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); + return; + +err: + kfree(clk_data); } CLK_OF_DECLARE_DRIVER(sun6i_rtc_clk, "allwinner,sun6i-a31-rtc", sun6i_rtc_clk_init);