Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp993833rdb; Fri, 1 Dec 2023 04:31:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjy5n7Sn8SL477lv4hrQXnTViJyN7Tn6PYNfuEFz/Er+v2hYnGUvRSDXvQnknsy+tntNwZ X-Received: by 2002:a17:90b:4b88:b0:286:40e7:e80 with SMTP id lr8-20020a17090b4b8800b0028640e70e80mr3898916pjb.42.1701433914477; Fri, 01 Dec 2023 04:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701433914; cv=none; d=google.com; s=arc-20160816; b=wHQ6RngKgIod+aAH3OZjqew0KgqNLRcynzCi+II8xk49/WMHkpebF8Z1/o5tMh7+wj NWuvcAl2JrraVuBCbGzcT41WXuRmmoGX/bFn6UHIgAQs7MZ5vFkL4v/BV7hliBSANPSc OpTDDCfVLTRjIjPxStIwk34dKd09ldULe6PxhPQFkNXzNQG4/V1edxfy1kI35A2AamSb SZbv+dFMm/VV7/BNpra8fNSc47XyS0699chSGk4aHl4ESiof9TVlsUjXiy0Ts+EZMM6w g3HEdhfoN1QIqblaImIdM2+fszNnszzUzFHu1KMBboSe7rh6UD5PD92ZjqKQhDRIr/In twqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=yAsaNOZu34ODY4nNGjbbjhL5Gy6DEQjObUgVreqNS4o=; fh=wqO7u5A9/rR/UsU8jnk5sOW6o7v6l0E9WElXNJFmDXA=; b=Dqd5tRePyyUbBbL+0Eu+gv/0/raC2fsN7iskGlbeiMrqEdGphy+ZwBNikg3u8QKqpm 3FihhboeAGLc0gRRzR3rccaY7XsALssBh7AR3mQDHH/KX5cWn5ZyT9Sj8qmeMt0HXHHl 3cXrdCAjzZlUjWlQN+wtbhqTzSs9Hmx3fv5pTWKbNKWYbD1/3x3g4CfqID7WZQJ7RfsU mZ9awjFYzd5ZE+2VNFPWdErDBK/z6pd11SMVsw1K1W/fgWzdguEPX74hhtXcFhSgYEde H7IBfKCqpwv6Wf//zRu7+mpLhm/qjuYdpoFRosVzzHW7yeyzEXus0H1nektCGY/44RM1 Spzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id co8-20020a17090afe8800b002839be230b2si5376809pjb.44.2023.12.01.04.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:31:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 17BA284AB818; Fri, 1 Dec 2023 04:31:44 -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 S1378845AbjLAMbV (ORCPT + 99 others); Fri, 1 Dec 2023 07:31:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378804AbjLAMbU (ORCPT ); Fri, 1 Dec 2023 07:31:20 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 713991717; Fri, 1 Dec 2023 04:31:26 -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 5CCEC1007; Fri, 1 Dec 2023 04:32:12 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.4.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AED743F5A1; Fri, 1 Dec 2023 04:31:24 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org Cc: lukasz.luba@arm.com, rafael@kernel.org, stable@vger.kernel.org Subject: [PATCH] powercap: DTPM: Fix the missing cpufreq_cpu_put() calls Date: Fri, 1 Dec 2023 12:32:05 +0000 Message-Id: <20231201123205.1996790-1-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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]); Fri, 01 Dec 2023 04:31:44 -0800 (PST) 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; } -- 2.25.1