Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3103132imd; Mon, 29 Oct 2018 01:32:50 -0700 (PDT) X-Google-Smtp-Source: AJdET5fV7BC3nAcBNE7btVj6Q9oN6kIuMIUYtn6Z9Di6ps/iJbuIHevw2viUmja0bubWdfTixiLd X-Received: by 2002:a17:902:e81:: with SMTP id 1-v6mr13401437plx.48.1540801970577; Mon, 29 Oct 2018 01:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540801970; cv=none; d=google.com; s=arc-20160816; b=xTc2uvkjUMN+3r3iCjKKTl513te+4+NypyrsDRtNnXAyKBzb+Sp2lFPR5geMw0K7n/ m2gm54UBqLbUhzQStQ0yYEmOe/1kjJZR+HNk3LjkRAIPwWep/POGsyYMNl/NKynpLQVt c3apsEmq5iME49BTQBVpGfkQhe7ZAHLYlLpwL9T89z7shiXoYtV8BLtRisEA4E1jTKu1 n6gZ+j9KnsK1ReFnvetgGMLNSiYpmyJPjSMxJVO/rzVXXLZx5b4MzMV6sVZQeiEL91BB 6jsPiiPs7eQFkShuGqJA6h2rCchJguKq3JWv2wmze53vU6NkQqbGoZbgUPJAyZCgfRup p3HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=Wauui6AaG6+JqkkxVhcxZaRQ2UIymGViXJ4cFSCbdKc=; b=FySkU2o6u8nvbCe+RduRAxwXbUSdFK3CqVgtwd+joq+7927T1xolh9WBusvrj/zgEF Y7fsqVn+EtKMySZbpfLRpdw/gJWI3JN6LXWAo1Idykyg46dE4de9LaSDZEVoSzUrkh0w kdhQPm8Rbot898w5dFRepwEKrRdADaLaiRbErjkWJbyp5hnqzr1Z0DNps0KS93AADg/I 7zhtT0wtZ8BdCjOjpRLg0ds1n2X07BjhASvoM20U5nZm9zNoou708MOdOSHODSsm7DXP vRQvmz+E6At9FfRuwXy5KuGzrzw7V7BHSqC1xzA5hEF7nKjm1XXC9SkoERj+EGGXiF08 U7aw== 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 w5-v6si9937310pfl.241.2018.10.29.01.32.35; Mon, 29 Oct 2018 01:32:50 -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 S1729433AbeJ2RSb (ORCPT + 99 others); Mon, 29 Oct 2018 13:18:31 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:62640 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729409AbeJ2RSb (ORCPT ); Mon, 29 Oct 2018 13:18:31 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id E33D8BDDB8C53D2B23E1; Mon, 29 Oct 2018 16:30:52 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w9T8Uiji044158; Mon, 29 Oct 2018 16:30:44 +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 2018102916305119-7358926 ; Mon, 29 Oct 2018 16:30:51 +0800 From: Yi Wang To: paul.burton@mips.com Cc: mturquette@baylibre.com, sboyd@kernel.org, linux-mips@linux-mips.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Yi Wang Subject: [PATCH v2] clk: boston: fix possible memory leak in clk_boston_setup() Date: Mon, 29 Oct 2018 16:31:47 +0800 Message-Id: <1540801907-31544-1-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-10-29 16:30:51, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-10-29 16:30:44, Serialize complete at 2018-10-29 16:30:44 X-MAIL: mse01.zte.com.cn w9T8Uiji044158 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'onecell' is malloced in clk_boston_setup(), but is not freed before leaving from the error handling cases. Signed-off-by: Yi Wang --- v2: fix syntax issue in comment, thanks to Sergei. 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