From patchwork Mon Oct 12 14:01:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lee X-Patchwork-Id: 286798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA74BC433DF for ; Mon, 12 Oct 2020 14:02:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5C962074D for ; Mon, 12 Oct 2020 14:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730575AbgJLOCk (ORCPT ); Mon, 12 Oct 2020 10:02:40 -0400 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:44951 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731074AbgJLOCG (ORCPT ); Mon, 12 Oct 2020 10:02:06 -0400 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.11137|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.00991924-0.0257103-0.96437; FP=0|0|0|0|0|-1|-1|-1; HT=ay29a033018047187; MF=frank@allwinnertech.com; NM=1; PH=DS; RN=8; RT=8; SR=0; TI=SMTPD_---.IiEJW-V_1602511313; Received: from allwinnertech.com(mailfrom:frank@allwinnertech.com fp:SMTPD_---.IiEJW-V_1602511313) by smtp.aliyun-inc.com(10.147.40.7); Mon, 12 Oct 2020 22:01:57 +0800 From: Frank Lee To: patrice.chotard@st.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, tiny.windzz@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH] cpufreq: sti-cpufreq: fix mem leak in sti_cpufreq_set_opp_info() Date: Mon, 12 Oct 2020 22:01:41 +0800 Message-Id: <20201012140141.20296-1-frank@allwinnertech.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Yangtao Li Use dev_pm_opp_put_prop_name() to avoid mem leak, which free opp_table. Signed-off-by: Yangtao Li Signed-off-by: Yangtao Li --- drivers/cpufreq/sti-cpufreq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/sti-cpufreq.c b/drivers/cpufreq/sti-cpufreq.c index a5ad96d29adc..9668a48dad33 100644 --- a/drivers/cpufreq/sti-cpufreq.c +++ b/drivers/cpufreq/sti-cpufreq.c @@ -222,7 +222,8 @@ static int sti_cpufreq_set_opp_info(void) opp_table = dev_pm_opp_set_supported_hw(dev, version, VERSION_ELEMENTS); if (IS_ERR(opp_table)) { dev_err(dev, "Failed to set supported hardware\n"); - return PTR_ERR(opp_table); + ret = PTR_ERR(opp_table); + goto err_put_prop_name; } dev_dbg(dev, "pcode: %d major: %d minor: %d substrate: %d\n", @@ -231,6 +232,10 @@ static int sti_cpufreq_set_opp_info(void) version[0], version[1], version[2]); return 0; + +err_put_prop_name: + dev_pm_opp_put_prop_name(opp_table); + return ret; } static int sti_cpufreq_fetch_syscon_registers(void)