Message ID | 20221123091201.199819-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 q4csp2679063wrr; Wed, 23 Nov 2022 01:15:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4d9fQv1MYBUCgrW6JaxGaJfXidq3ZQLfxLNApXiMemf60OCXErJbubIHND0r0/ssQZw+q2 X-Received: by 2002:a63:5910:0:b0:42b:68a1:4207 with SMTP id n16-20020a635910000000b0042b68a14207mr13353497pgb.326.1669194946603; Wed, 23 Nov 2022 01:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669194946; cv=none; d=google.com; s=arc-20160816; b=RcPvQs70cVfuEjHHOGOaR3EHTn2IpnqF7MtzDa45jriJHSWjji/Pir7bxbMCBBYMSR 8CWSAXI2MjIjdgpH6STyWWHcmMdzsHXzD3fXEW592XX85ndWTWoRU0bHAo1vTqcSeCmQ JBqFjlEC8Aa8jXN8vIZ9ETl/Ql6H23me3vQilQxLrtE26HBFu1f9edoHraFKmodiuFrm XMs7e5MHMWkWe7iWlvP0YuY+lN5jbVWUdc7DF0RDlU9UtYExxvzHV3dWKpLqiRTLj8bg UE4rBLomUn7NtPtZMmP1bx3uQPCvFlFtIAFPKoLMoq4Dg2IsX7ALfvQhW/Zz5X/QRKUh z5dQ== 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=54jlT1GxN7z+rD4XiG4nTxDxtk0/RWSwNKiy+p2uLbA=; b=Ktgcgw75B9aYD+w94+ecbYlEEsDl/jYxWAX/xoWZEPKvJLR73gEL2tZpe5mVpbmNtP 8bWMHUETsTQ7T+9/UQfJ7yz3LF5cW++hMBuRBiAtID3RhVMpmI/LHRus0dVSREfgNaBr jTA64nqX3rOqieHMeUiaSYQ8yTTwjgLtrzm2TnSXAXuNhyxPEw4uELR8WCVHLSx6WFHI LrE0FrAHn2wb8Og4m/jGlqFuHGoAHelGIDq5+jATIcYjDWdbi8Pih9fsJZyLGQ7+S7p2 NaKBpY/S6UQ6fjhhPIGP+VUbUjEHlvPiZUI689875IGdEgjrH5bCdTm86Y656zii419k V8MA== 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 e21-20020a170902d39500b001892abd19easi5567455pld.157.2022.11.23.01.15.33; Wed, 23 Nov 2022 01:15:46 -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 S237279AbiKWJPO (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Wed, 23 Nov 2022 04:15:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237271AbiKWJPI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 23 Nov 2022 04:15:08 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F92A87578; Wed, 23 Nov 2022 01:15:06 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NHFnP2GyFzmV6V; Wed, 23 Nov 2022 17:14:33 +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; Wed, 23 Nov 2022 17:15:04 +0800 From: Xiu Jianfeng <xiujianfeng@huawei.com> To: <mturquette@baylibre.com>, <sboyd@kernel.org>, <heiko@sntech.de>, <mturquette@linaro.org> CC: <linux-clk@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-rockchip@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH v2] clk: rockchip: Fix memory leak in rockchip_clk_register_pll() Date: Wed, 23 Nov 2022 17:12:01 +0800 Message-ID: <20221123091201.199819-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: dggems701-chm.china.huawei.com (10.3.19.178) 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?1750277760293465412?= X-GMAIL-MSGID: =?utf-8?q?1750277760293465412?= |
Series |
[v2] clk: rockchip: Fix memory leak in rockchip_clk_register_pll()
|
|
Commit Message
Xiu Jianfeng
Nov. 23, 2022, 9:12 a.m. UTC
If clk_register() fails, @pll->rate_table may have allocated memory by
kmemdup(), so it needs to be freed, otherwise will cause memory leak
issue, this patch fixes it.
Fixes: 90c590254051 ("clk: rockchip: add clock type for pll clocks and pll used on rk3066")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
v2: move kfree(pll->rate_table) to the err_pll block
---
drivers/clk/rockchip/clk-pll.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Wed, 23 Nov 2022 17:12:01 +0800, Xiu Jianfeng wrote: > If clk_register() fails, @pll->rate_table may have allocated memory by > kmemdup(), so it needs to be freed, otherwise will cause memory leak > issue, this patch fixes it. > > Applied, thanks! [1/1] clk: rockchip: Fix memory leak in rockchip_clk_register_pll() commit: 739a6a6bbdb793bd57938cb24aa5a6df89983546 Best regards,
diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c index 4b9840994295..2d42eb628926 100644 --- a/drivers/clk/rockchip/clk-pll.c +++ b/drivers/clk/rockchip/clk-pll.c @@ -1197,6 +1197,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx, return mux_clk; err_pll: + kfree(pll->rate_table); clk_unregister(mux_clk); mux_clk = pll_clk; err_mux: