Received: by 10.192.165.148 with SMTP id m20csp5538489imm; Wed, 9 May 2018 06:42:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZobCh37YR+XhK6jL9tZQrqb0bk1OOSYca8SGKTnFmzp8YVfMIl7UHudIRXNdxrikM+SBg+A X-Received: by 10.98.17.82 with SMTP id z79mr43629500pfi.135.1525873330179; Wed, 09 May 2018 06:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525873329; cv=none; d=google.com; s=arc-20160816; b=Ffb/bH8O7KijzEKE3ZfsfnJSoGOeYBEhigqeTRXxZI2XEXo4YW9BR87UwXkqztKv/d iC9URRgDwsXgbWjb5LyWIn9XfRmRSfAQ3tUYqKXbiDsqdXq4GgNVmlfQUNis7j1171Vs 8n7kwGCyPX1RiZe4kWfXXc18jOlm26BPpShlrgbDVopuNxrUw9a4HvuLRJWXssUAUk66 hK9A735J8SgViphdszUGXZ+gy1enswxSgX5SPiUZ/5ES6BBLS0+zN62vqh4bkltSg05z 5aMzRA479e61jfKTGbU1ifHt9wXmIFWYrLNhiuTQOXsGmDZZX9f2A/OvsSx5Sy3d1Ckp 43kQ== 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:arc-authentication-results; bh=f8EcCQtbY2B1zSdVu/G6yI/HdZb4Bv/NDGlq2OYMaCE=; b=CkKPA9l4M9HjkdLnP3zdjmOmPeRQQlFNwnUGCjV5ybBh/4CsZhVZgW8Hs9irIkuKqN eH27c0oKqRCU1mO5cYjL/6CjcyoiRLvfpLTke1gWuNN668+hFEBRuk+t/xjgGs9uxx3Z WmIjJO5bHxsP5ekCRcYqB/2SCWoJp28pIqNudMmz3UPujasaIbmV3wT7biU9XhLPVmvJ YA/u3vb+6hPnW3RbSH7FqHe4HYXDQADgmHse1ZYsGnT+Za/fFiaGThwtD7vYICWn3IaD /5L/umx6Iv7QtsbMrkEsdhkyB1Pk4qASF/Y7gV7y9sCA8CADjPlniUELEl3bNftetZuG lR6g== ARC-Authentication-Results: i=1; mx.google.com; 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=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10-v6si17002534pgv.446.2018.05.09.06.41.55; Wed, 09 May 2018 06:42:09 -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; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934939AbeEINkp (ORCPT + 99 others); Wed, 9 May 2018 09:40:45 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:56493 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934630AbeEINko (ORCPT ); Wed, 9 May 2018 09:40:44 -0400 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 1fGPKa-00021a-50; Wed, 09 May 2018 13:40:32 +0000 From: Colin King To: Paul Burton , Michael Turquette , Stephen Boyd , linux-mips@linux-mips.org, linux-clk@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: boston: fix memory leak of 'onecell' on error return paths Date: Wed, 9 May 2018 14:40:31 +0100 Message-Id: <20180509134031.11611-1-colin.king@canonical.com> X-Mailer: git-send-email 2.17.0 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 From: Colin Ian King There are several error return paths that don't free up onecell and hence we have some memory leaks. Add an error exit path that kfree's onecell to fix the leaks. Signed-off-by: Colin Ian King --- drivers/clk/imgtec/clk-boston.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/clk/imgtec/clk-boston.c b/drivers/clk/imgtec/clk-boston.c index 15af423cc0c9..d6bc468ff551 100644 --- a/drivers/clk/imgtec/clk-boston.c +++ b/drivers/clk/imgtec/clk-boston.c @@ -73,27 +73,34 @@ static void __init clk_boston_setup(struct device_node *np) hw = clk_hw_register_fixed_rate(NULL, "input", NULL, 0, in_freq); if (IS_ERR(hw)) { pr_err("failed to register input clock: %ld\n", PTR_ERR(hw)); - return; + goto error; } onecell->hws[BOSTON_CLK_INPUT] = hw; hw = clk_hw_register_fixed_rate(NULL, "sys", "input", 0, sys_freq); if (IS_ERR(hw)) { pr_err("failed to register sys clock: %ld\n", PTR_ERR(hw)); - return; + goto error; } onecell->hws[BOSTON_CLK_SYS] = hw; hw = clk_hw_register_fixed_rate(NULL, "cpu", "input", 0, cpu_freq); if (IS_ERR(hw)) { pr_err("failed to register cpu clock: %ld\n", PTR_ERR(hw)); - return; + goto error; } onecell->hws[BOSTON_CLK_CPU] = hw; err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, onecell); - if (err) + if (err) { pr_err("failed to add DT provider: %d\n", err); + goto error; + } + return; + +error: + kfree(onecell); + return; } /* -- 2.17.0