Message ID | 20221122124627.174403-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 q4csp2180146wrr; Tue, 22 Nov 2022 04:51:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6UT5dVH8NZ0twdDpEjNUwMjTU7jnMfzYT5yd9TGh2BPsVLfr2EBuqYR9+9muI7gBRu+Gkw X-Received: by 2002:a05:6402:5406:b0:467:4b3d:f2ed with SMTP id ev6-20020a056402540600b004674b3df2edmr3741700edb.101.1669121478791; Tue, 22 Nov 2022 04:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669121478; cv=none; d=google.com; s=arc-20160816; b=ffoj17HYjQCVV+5ExY+hmreTvgNYmtvx/imUCccAA1QPfpskcHQOL1yY3aiRNyElQ4 IF/T/OMj7EFrGjcQ6385RTljb8Ka7/8jByJhMb99oJqrF7qH2Xvcw7Iq8UPSMEbBH+vN CAl/0z3CTbGWAdmI5eTq650EUPa2qtOSJEJClhyfWqo4DfoHGULHGZQ4HRN+J5K0/JMx jCSsokrsnH9dkiViNHYK0fALdaOs6MmlNEOrtbyG9rC/QLCgDV7g7wbFl3V4U26o6m+K jQFafRX1z1GyUUg56erbDTvbdUPWnSPMXgUDWrygksdUiRBB0tftSas8PiDZK36CJc+J sJHQ== 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=c4BqBt8PX4+/5esJdkkQ0lMCGexWIZayJPcXuhNmuaA=; b=ZJ+TdTeKobMeHmrtbv/at7Tskzc5Zj145/rmdy6vEKz42H5RXZOdCminflRztpYCnV 35p23eGZSpkoQUs99wttnC7H48WTxBpNhzRFlk3EAIeotIzbXiBArtwtFRAm1DEHxP/j ejHpWSh9Ddl69+shzeajBUutE6ZXXs/oeRH1HGHKleOhYdqEWtB9unngb4pbrq0WVf8K xNM4IOHDcEOCYQoCccpO+2UQ+9MF4KT7BdEiF+90RPWSo39dkd3qaGGenuvHu65pcSXK uPMqcQcG0osSer9reXVQ+c94AbawzNahl+jPjWLk4qEmHEKLXyGFJYZy593ZK/F0MEqJ FeaQ== 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 h18-20020aa7cdd2000000b004696a0da4cfsi6021165edw.358.2022.11.22.04.50.54; Tue, 22 Nov 2022 04:51:18 -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 S232569AbiKVMtn (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Tue, 22 Nov 2022 07:49:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231487AbiKVMtl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 22 Nov 2022 07:49:41 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83A26606AB; Tue, 22 Nov 2022 04:49:40 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NGkbL2hcyzHw4C; Tue, 22 Nov 2022 20:49:02 +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 20:49:38 +0800 From: Xiu Jianfeng <xiujianfeng@huawei.com> To: <agross@kernel.org>, <andersson@kernel.org>, <konrad.dybcio@linaro.org>, <rafael@kernel.org>, <viresh.kumar@linaro.org>, <mani@kernel.org> CC: <linux-arm-msm@vger.kernel.org>, <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH -next] cpufreq: qcom-hw: Fix memory leak in qcom_cpufreq_hw_driver_probe() Date: Tue, 22 Nov 2022 20:46:27 +0800 Message-ID: <20221122124627.174403-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: dggems704-chm.china.huawei.com (10.3.19.181) 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?1750200501377550480?= X-GMAIL-MSGID: =?utf-8?q?1750200723746717940?= |
Series |
[-next] cpufreq: qcom-hw: Fix memory leak in qcom_cpufreq_hw_driver_probe()
|
|
Commit Message
Xiu Jianfeng
Nov. 22, 2022, 12:46 p.m. UTC
If devm_clk_hw_register() fails, clk_init.name should be freed before
return error, otherwise will cause memory leak issue, fix it.
Fixes: 84063a1cbe9e ("cpufreq: qcom-hw: Add CPU clock provider support")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
drivers/cpufreq/qcom-cpufreq-hw.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Tue, Nov 22, 2022 at 08:46:27PM +0800, Xiu Jianfeng wrote: > If devm_clk_hw_register() fails, clk_init.name should be freed before > return error, otherwise will cause memory leak issue, fix it. > > Fixes: 84063a1cbe9e ("cpufreq: qcom-hw: Add CPU clock provider support") > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Thanks, Mani > --- > drivers/cpufreq/qcom-cpufreq-hw.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > index 1bd1e9ae5308..340fed35e45d 100644 > --- a/drivers/cpufreq/qcom-cpufreq-hw.c > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c > @@ -723,6 +723,7 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) > ret = devm_clk_hw_register(dev, &data->cpu_clk); > if (ret < 0) { > dev_err(dev, "Failed to register clock %d: %d\n", i, ret); > + kfree(clk_init.name); > return ret; > } > > -- > 2.17.1 >
On 22-11-22, 20:46, Xiu Jianfeng wrote: > If devm_clk_hw_register() fails, clk_init.name should be freed before > return error, otherwise will cause memory leak issue, fix it. > > Fixes: 84063a1cbe9e ("cpufreq: qcom-hw: Add CPU clock provider support") > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> > --- > drivers/cpufreq/qcom-cpufreq-hw.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > index 1bd1e9ae5308..340fed35e45d 100644 > --- a/drivers/cpufreq/qcom-cpufreq-hw.c > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c > @@ -723,6 +723,7 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) > ret = devm_clk_hw_register(dev, &data->cpu_clk); > if (ret < 0) { > dev_err(dev, "Failed to register clock %d: %d\n", i, ret); > + kfree(clk_init.name); > return ret; > } Squashed with the original commit and added your SoB. Thanks.
diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 1bd1e9ae5308..340fed35e45d 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -723,6 +723,7 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) ret = devm_clk_hw_register(dev, &data->cpu_clk); if (ret < 0) { dev_err(dev, "Failed to register clock %d: %d\n", i, ret); + kfree(clk_init.name); return ret; }