Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp962452rdb; Wed, 6 Dec 2023 05:11:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHla1CgzLXnr8ehZc3aH4KsASVscBDmbBMP3G15I3x8Gh2ie1vBigIr+VBpQtoSkjjfPiQ X-Received: by 2002:a05:6e02:804:b0:35d:59a2:bd2 with SMTP id u4-20020a056e02080400b0035d59a20bd2mr905953ilm.104.1701868315479; Wed, 06 Dec 2023 05:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701868315; cv=none; d=google.com; s=arc-20160816; b=kV2hu7Q9gprxX/7ZoqPNDZ6wmNT7/WtKm36dtgok5mW+sRnjpYke15boTmoTUC63Zz /DutouJJQ8DoxDaOogMnBF6P2hLXH0lYMC+1K1UcZkzEbzupi7w5bLoaYv9QSXwb9mKe 32kOhCtnpti55zf4wsM0t71NqkZgPynqcEypUgfRHWDO0mJbAbemQ3qP9NI6epCml6EA SiMDFhkeFx1ptXovuxrqp8tA/5RLc9XMaJRZhnM18I4NZaMI6iKPgfjlnMj1FgATSnXj 6Ht1VJljqKYtC7x8sJlcX1eDjuyBDjbIPQUPuKzAxoEgGtwlsGjhi7wpeDAlnBE7yTa4 sRPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=emU2R/Rv3apDODVCBJ723fmDNOhA1LDixDXyRijOdLQ=; fh=PkDY980M29ED0PDzBVOJfK9sT/h2y1bkSKprQMOy/gs=; b=NknGbvM19ok4pLlKUEJ4v8A/IktnkP1SyCp/0YcF+8JUq7w53aEzzafN4j1hFUqLBi 0NLCbgIhdRatTvOPrtjLE0ab75/PSTRugDoL+Z+YQNfjFuUVLzkAvImf5B/PWChY3TaV kKBaEJYsktXtgQVpItBtoRoTb4dsyHmGt+LJFLo81y5FewTgi1PiQ+lzrgRKBdknE7zl Of0ScWVvOhoFRhX7xeWpXpMLRLKlZiQN4U+yRnWM2o9CLCZHAo68rLGpCnImSQejMzce Agg9R6MUAQVxbykeMKCr9t5y5yAT124Xk/LdzayshVJ435F0Ok2TGSwhXccVld5jX8Jl SYOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id f8-20020a635548000000b005c6c9524f93si415251pgm.766.2023.12.06.05.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 05:11:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 5DA5A80251BB; Wed, 6 Dec 2023 05:11:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378416AbjLFNLa (ORCPT + 99 others); Wed, 6 Dec 2023 08:11:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378407AbjLFNL3 (ORCPT ); Wed, 6 Dec 2023 08:11:29 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0AB39AC; Wed, 6 Dec 2023 05:11:35 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 624921474; Wed, 6 Dec 2023 05:12:21 -0800 (PST) Received: from [10.57.1.114] (unknown [10.57.1.114]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 69AFB3F5A1; Wed, 6 Dec 2023 05:11:34 -0800 (PST) Message-ID: <972bf6bc-20ca-4588-bed0-c95b1b24c552@arm.com> Date: Wed, 6 Dec 2023 13:12:35 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] powercap: DTPM: Fix the missing cpufreq_cpu_put() calls Content-Language: en-US To: "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, stable@vger.kernel.org References: <20231201123205.1996790-1-lukasz.luba@arm.com> From: Lukasz Luba In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 05:11:52 -0800 (PST) On 12/5/23 19:54, Rafael J. Wysocki wrote: > On Fri, Dec 1, 2023 at 1:31 PM Lukasz Luba wrote: >> >> The policy returned by cpufreq_cpu_get() has to be released with >> the help of cpufreq_cpu_put() to balance its kobject reference counter >> properly. >> >> Add the missing calls to cpufreq_cpu_put() in the code. >> >> Fixes: 0aea2e4ec2a2 ("powercap/dtpm_cpu: Reset per_cpu variable in the release function") >> Fixes: 0e8f68d7f048 ("powercap/drivers/dtpm: Add CPU energy model based support") >> Cc: # v5.10+ >> Signed-off-by: Lukasz Luba >> --- >> drivers/powercap/dtpm_cpu.c | 17 +++++++++++++---- >> 1 file changed, 13 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c >> index 45bb7e2849d7..aac278e162d9 100644 >> --- a/drivers/powercap/dtpm_cpu.c >> +++ b/drivers/powercap/dtpm_cpu.c >> @@ -152,6 +152,8 @@ static void pd_release(struct dtpm *dtpm) >> if (policy) { >> for_each_cpu(dtpm_cpu->cpu, policy->related_cpus) >> per_cpu(dtpm_per_cpu, dtpm_cpu->cpu) = NULL; >> + >> + cpufreq_cpu_put(policy); >> } >> >> kfree(dtpm_cpu); >> @@ -204,12 +206,16 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent) >> return 0; >> >> pd = em_cpu_get(cpu); >> - if (!pd || em_is_artificial(pd)) >> - return -EINVAL; >> + if (!pd || em_is_artificial(pd)) { >> + ret = -EINVAL; >> + goto release_policy; >> + } >> >> dtpm_cpu = kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL); >> - if (!dtpm_cpu) >> - return -ENOMEM; >> + if (!dtpm_cpu) { >> + ret = -ENOMEM; >> + goto release_policy; >> + } >> >> dtpm_init(&dtpm_cpu->dtpm, &dtpm_ops); >> dtpm_cpu->cpu = cpu; >> @@ -231,6 +237,7 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent) >> if (ret) >> goto out_dtpm_unregister; >> >> + cpufreq_cpu_put(policy); >> return 0; >> >> out_dtpm_unregister: >> @@ -242,6 +249,8 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent) >> per_cpu(dtpm_per_cpu, cpu) = NULL; >> kfree(dtpm_cpu); >> >> +release_policy: >> + cpufreq_cpu_put(policy); >> return ret; >> } >> >> -- > > Applied as 6.7-rc material with the Cc: stable tag fixed. > > Thanks! > Thank you Rafael!