Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3079632imd; Mon, 29 Oct 2018 01:04:50 -0700 (PDT) X-Google-Smtp-Source: AJdET5fZWMmOhXQMU4JWfQZfS+qwkJHp0XphCO94R25s4HGycbYcHJeZR4IUXCh5sVaEE64ggymQ X-Received: by 2002:a63:fd09:: with SMTP id d9-v6mr13123208pgh.164.1540800289851; Mon, 29 Oct 2018 01:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540800289; cv=none; d=google.com; s=arc-20160816; b=jhcJ8eKwp4GCBLEFE1JhttSqbnz6DDUX4f+ce3aS6z+0kA+hfMrCrmR7M0BSDposmb uKFTrvPbZTQOzwZ3uoKJzpi0qXCx65GHSih//WthOeUkamqMZ0GEHKOgUcK8V7noaq5i w0gRXA7gCoxu2FtUydE4B6r0KED3Zb4pxj/PN3o2c1mJkFHeO2ra0N3feWNc7F7VMR/N pCwxJPRpany1aqpaFklvi6Dn5pPVYqbKc1EwL/Lfmwn9wEWhwc+5Zn/O7JQoAxGFg0Ew vwrTIt+PCGiaIWc2QzxSod1NNMD25/6yk+nvkYfWCdCKjLloYid4LVFqw2OcqJUd87nP rZAA== 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=73VhF2wnGwqAnZJUZwFdlTsJKx4QQDXXge6atDMgQcQ=; b=A4y3jYWh/ByE5vq5CjXSiuBROZdLIK7UvEo8ayYcMiAEO7N3MFtl6J2mNUbLwFxxag FuqQX2IrfrcpW6L4OZJv9lnPgJwDD5HWgTxN8cjfp4v3/pELSsRvY++5MkHnY5hpSQzP gGDIgEaqcA5YrqJFqzN37tnIOy4+x6H7TJXGiES8pXcqg6soT11pGpUFGowB2g1+tRVz ucsucPwv9I94uWKRtCIBGMol7oEYVEp1InvBhvE2By1MciYK0Es7dmaazye2RDToLizE 3i8RQKn5/JUDhWTPKVqMXJ1HuACT7Zez4EmOeQ0ZV1y1koP53WNLRV/oDdKdITMehvIT yhJA== 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 n2-v6si19637599plk.255.2018.10.29.01.04.34; Mon, 29 Oct 2018 01:04:49 -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 S1729217AbeJ2Qvm (ORCPT + 99 others); Mon, 29 Oct 2018 12:51:42 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:38726 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbeJ2Qvl (ORCPT ); Mon, 29 Oct 2018 12:51:41 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 266BD12846B20A020724; Mon, 29 Oct 2018 16:03:46 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w9T83YTt088562; Mon, 29 Oct 2018 16:03:34 +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 2018102916034081-7352366 ; Mon, 29 Oct 2018 16:03:40 +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] clk: boston: fix possible memory leak in clk_boston_setup() Date: Mon, 29 Oct 2018 16:04:37 +0800 Message-Id: <1540800277-24524-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:03:40, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-10-29 16:03:34, Serialize complete at 2018-10-29 16:03:34 X-MAIL: mse01.zte.com.cn w9T83YTt088562 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 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