Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5725617imd; Wed, 31 Oct 2018 00:41:39 -0700 (PDT) X-Google-Smtp-Source: AJdET5e4Q8N/8sRMPJm5YdoFt0sFp+sinXUijizVhoMs1Fl5qjdZXR+QYArgxIowB7yIZh5om2yr X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr2223022pla.131.1540971699862; Wed, 31 Oct 2018 00:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540971699; cv=none; d=google.com; s=arc-20160816; b=i4DgDOF59AZx9yXCI2y+mhDCue9N7c3VPw60/ADsekgpl8+tKy4h/KIpXhz4pDJYHu 9ojIwllEMBUqVv+tPGqe0W6A5mb1Gm1yrXaqpJC++aDsnoUDF19eHveY0d40f8tJrhAp x6RB1xQ91nWY7VwK+21xoTpcDere+Z6wz3yrxUDO7krU33ZgEx1niXP3GC5h78H0evKB oa2Ue7ZJzkDQ/F8PzMJ3f01FS/ReVdcVdy8vG0taLQYJ4XIBs1sGKafJgb9w02I6evmG AJ5BxB/wb1bVj8C0ED6+jfMQVVySd7HpvgYKe/pXLE/3DURZ9V0sgh3Hk7n3UPYtjix5 mS0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=1L1QISIJmmUWUyYGEV60uwPB3IFnl6bwwJXJxFdDOzE=; b=unjQlT8uztV6RR5u6xupucYNZJwpkfI2Hc7YQe/OcngzHvR7xIgsG1mIY5gZaMwnda cmeoktfiDu21+qPHKXbccK+4qySvR3EpLEPE1FFtmEPY2kII6UsiFF97Q12uN2T/FXft CV+zAlSL8TMZaio1oTES9VSZjNm4qCtxTuE6iKAOgI0Oo1yupQi3SGcDrvLkvyVWRofM Wc/OjsFRxGJ1xjuW3+OCO6s5auj7B3FNzcHjcjHwfGOaPNIXJ3uceXAWPDSeZGxZOSRv L6VjetpVKGnJgWWJGx++ImiwzzX0OIMsYIAUqThTi1A/1pxTXb8SsRgzS+PnNpctZ4aU dU4g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34-v6si26401528pgm.550.2018.10.31.00.41.24; Wed, 31 Oct 2018 00:41:39 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727372AbeJaQh0 (ORCPT + 99 others); Wed, 31 Oct 2018 12:37:26 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:58492 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbeJaQh0 (ORCPT ); Wed, 31 Oct 2018 12:37:26 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 007A5BFE1B26685DCA5D; Wed, 31 Oct 2018 15:39:53 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w9V7dlrR015819; Wed, 31 Oct 2018 15:39:47 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018103115400974-7800103 ; Wed, 31 Oct 2018 15:40:09 +0800 From: Yi Wang To: paul.burton@mips.com, sboyd@kernel.org Cc: mturquette@baylibre.com, linux-mips@linux-mips.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Yi Wang Subject: [PATCH v3 1/2] clk: boston: fix possible memory leak in clk_boston_setup() Date: Wed, 31 Oct 2018 15:41:41 +0800 Message-Id: <1540971702-3133-2-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540971702-3133-1-git-send-email-wang.yi59@zte.com.cn> References: <1540971702-3133-1-git-send-email-wang.yi59@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-10-31 15:40:09, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-10-31 15:39:39, Serialize complete at 2018-10-31 15:39:39 X-MAIL: mse01.zte.com.cn w9V7dlrR015819 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Smatch report warnings: drivers/clk/imgtec/clk-boston.c:76 clk_boston_setup() warn: possible memory leak of 'onecell' drivers/clk/imgtec/clk-boston.c:83 clk_boston_setup() warn: possible memory leak of 'onecell' drivers/clk/imgtec/clk-boston.c:90 clk_boston_setup() warn: possible memory leak of 'onecell' 'onecell' is malloced in clk_boston_setup(), but not be freed before leaving from the error handling cases. Signed-off-by: Yi Wang --- drivers/clk/imgtec/clk-boston.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/clk/imgtec/clk-boston.c b/drivers/clk/imgtec/clk-boston.c index 15af423..f5d54a6 100644 --- a/drivers/clk/imgtec/clk-boston.c +++ b/drivers/clk/imgtec/clk-boston.c @@ -73,27 +73,32 @@ 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) pr_err("failed to add DT provider: %d\n", err); + + return; + +error: + kfree(onecell); } /* -- 1.8.3.1