Message ID | 20221122152353.204132-1-xiujianfeng@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2282726wrr; Tue, 22 Nov 2022 07:37:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf6GnLUeg8z3uFuRcSenoSJ0sCMQMeXVEc7IiNv2zT9Gv/7kGD4n8wbKougNR39mDjHwCxJg X-Received: by 2002:a17:907:b014:b0:7b4:86be:f3e3 with SMTP id fu20-20020a170907b01400b007b486bef3e3mr12555322ejc.741.1669131471809; Tue, 22 Nov 2022 07:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669131471; cv=none; d=google.com; s=arc-20160816; b=xKG/sRYokjByOP0r+cfWYKpXzipUWXF0JRrZLUYxLPJ3AjD4NOvBk78MPVrfLltbeV H8viPhGnyvi+wyJ3/J2mZVlcynF5E/fVbZJ3jz8WJHCJ84JBaLXwOHPrQ4mMnHsyZjEh gQLu+eZkMraCtSZyPwAsSeiowZjLkZaHcGbcw9sY/l239h2M98YquZjBrjQV2CePADYh p8oHF3aMp0JEZTAUH6OBYWZ50X1fnQ2JMSF/z3r9jbVe3diAnDgG5j86d+CVY0mYmt7S KUPItOG0tk/AwX4p/rgoNyq6lkaeyThlgY+MpR07cKh8v6294Uj39N+iDjhTRol7e0fO NJwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=D9dvYo+E61xZyC4fQZUMELtq9qY734eq9stDY6l4veI=; b=L8vElAr8+FDow5AvQtoarS/6u+sybbQ+C+G+8dnU2hvyaAkQWVNRulOpi2SMYSMsYv oHn+ORp4k7UUzqP/QDZeHW+k5OyShYZ9N9RqVHRGhz5HQwD8ioejuhTy2/JgArI8Z1Yi xd00cs6KMSh77oRtTpks+FCmBFdjtVaMh7PtOBKH/XWYxCxCuwZadienpsU7GOJbHbev PCiPt2EQoqqHWtYaGbfzLjgLDT3Comt8bjOsrvV9KSPQUtOFyGBCuCO8H+HPuZZtades tCY9BfagXwkDzk2Kz1uhTF9Yr4A2gYZMF6769b2rDIW+byVXwVOX2gtff/mqzVr794x3 r8eA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv17-20020a17090760d100b0078dbd939dacsi11858885ejc.545.2022.11.22.07.37.23; Tue, 22 Nov 2022 07:37:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233868AbiKVP1Q (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Tue, 22 Nov 2022 10:27:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232742AbiKVP1N (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 22 Nov 2022 10:27:13 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB1D69DC9; Tue, 22 Nov 2022 07:27:11 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NGp5B4knsz15MmH; Tue, 22 Nov 2022 23:26:38 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 22 Nov 2022 23:27:08 +0800 From: Xiu Jianfeng <xiujianfeng@huawei.com> To: <mturquette@baylibre.com>, <sboyd@kernel.org>, <nobuhiro1.iwamatsu@toshiba.co.jp> CC: <linux-clk@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] clk: visconti: Fix memory leak in visconti_register_pll() Date: Tue, 22 Nov 2022 23:23:53 +0800 Message-ID: <20221122152353.204132-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750211202194256214?= X-GMAIL-MSGID: =?utf-8?q?1750211202194256214?= |
Series |
clk: visconti: Fix memory leak in visconti_register_pll()
|
|
Commit Message
Xiu Jianfeng
Nov. 22, 2022, 3:23 p.m. UTC
@pll->rate_table has allocated memory by kmemdup(), if clk_hw_register()
fails, it should be freed, otherwise it will cause memory leak issue,
this patch fixes it.
Fixes: b4cbe606dc36 ("clk: visconti: Add support common clock driver and reset driver")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
drivers/clk/visconti/pll.c | 1 +
1 file changed, 1 insertion(+)
Comments
Hi Xiu, Thanks for your patch! > -----Original Message----- > From: Xiu Jianfeng <xiujianfeng@huawei.com> > Sent: Wednesday, November 23, 2022 12:24 AM > To: mturquette@baylibre.com; sboyd@kernel.org; iwamatsu nobuhiro(岩松 信 > 洋 □SWC◯ACT) <nobuhiro1.iwamatsu@toshiba.co.jp> > Cc: linux-clk@vger.kernel.org; linux-arm-kernel@lists.infradead.org; > linux-kernel@vger.kernel.org > Subject: [PATCH] clk: visconti: Fix memory leak in visconti_register_pll() > > @pll->rate_table has allocated memory by kmemdup(), if clk_hw_register() > fails, it should be freed, otherwise it will cause memory leak issue, this patch > fixes it. > > Fixes: b4cbe606dc36 ("clk: visconti: Add support common clock driver and > reset driver") > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Acked-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp> Best regards, Nobuhiro > --- > drivers/clk/visconti/pll.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/clk/visconti/pll.c b/drivers/clk/visconti/pll.c index > a484cb945d67..1f3234f22667 100644 > --- a/drivers/clk/visconti/pll.c > +++ b/drivers/clk/visconti/pll.c > @@ -277,6 +277,7 @@ static struct clk_hw *visconti_register_pll(struct > visconti_pll_provider *ctx, > ret = clk_hw_register(NULL, &pll->hw); > if (ret) { > pr_err("failed to register pll clock %s : %d\n", name, ret); > + kfree(pll->rate_table); > kfree(pll); > pll_hw_clk = ERR_PTR(ret); > } > -- > 2.17.1
Quoting Xiu Jianfeng (2022-11-22 07:23:53) > @pll->rate_table has allocated memory by kmemdup(), if clk_hw_register() > fails, it should be freed, otherwise it will cause memory leak issue, > this patch fixes it. > > Fixes: b4cbe606dc36 ("clk: visconti: Add support common clock driver and reset driver") > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> > --- Applied to clk-next
diff --git a/drivers/clk/visconti/pll.c b/drivers/clk/visconti/pll.c index a484cb945d67..1f3234f22667 100644 --- a/drivers/clk/visconti/pll.c +++ b/drivers/clk/visconti/pll.c @@ -277,6 +277,7 @@ static struct clk_hw *visconti_register_pll(struct visconti_pll_provider *ctx, ret = clk_hw_register(NULL, &pll->hw); if (ret) { pr_err("failed to register pll clock %s : %d\n", name, ret); + kfree(pll->rate_table); kfree(pll); pll_hw_clk = ERR_PTR(ret); }