Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp528251rdb; Tue, 5 Dec 2023 11:55:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHopLEXg4VApPkL8juCkiwPrvPjZzzzMH3pBq8BfqCrvB6PmrOMZH2Qq0X+tCpdYfD0BiYQ X-Received: by 2002:a05:6a00:1784:b0:6ce:2732:278 with SMTP id s4-20020a056a00178400b006ce27320278mr1654987pfg.39.1701806102809; Tue, 05 Dec 2023 11:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701806102; cv=none; d=google.com; s=arc-20160816; b=ffS7U2x7eEy26rIMidP/Wm31KIzuNH4mUq3WzS/L1S5sWBA/zKwW/1/BUc4o9WMdSV bM8szRg7lvjQ/UkHxuibSEepSQ/XO5cGcu5Tn40VoAjYJaVzPkuhguotOTMv3DKd60Re oGjjdhS33CLAiDsKwY5fTUf7tmLPy8taiMygbY5T7351YYhLF0eyvX2Tp53K0g4Xby1W Xj2lnwlIG02FfkIY7c9b3snFNzGfW+IQYh2gExvkFKhRXhOTfd+1VlgVMkfqjApXQOQl cCSF77gUpJ8qNI/aap8NLtqwE/sEs0MHBojfPZYx3rLG7xiftDDbtlgTvELUSRUY4Yup qTQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=I9jNbR2wdcrM3CnxQ3H+njlnQG6o40TYwfNsO/uh7Hk=; fh=IXI57RYZJ5ML2GINoWb2R70DHYEZScdvccJy15A0qMs=; b=uuh4HxN3MyoashI/+vFZwAoZj4hZIDvxhKhocPK6qzCub5ZoOI5L8jqUZ6XaSxTqxX evAqOunr00AcSsO9mrbsyRnhzmfKGqH9FhnAgQZKCAzQ2KWLUd6fIlCWhg4GgC4uwgno RLEKgSA/AGYiClvifDrsX+F++PB7tHefZkeQd1FdGZONivJADWm2U+Fp/TTw1g9bjals IckUzK1ESfSVadVIpcNdfEO7oSMum0lDpHV8/PcJppI+HzECpwE8CZOPfZ70IMOUX+cc h9sAH0ULUPbZLw/PGfaTzfMXy1iNDBOhha5rcvIhlcNXA8W+TFiETTsoQJXwgMx6HbhK wfWA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p9-20020a056a0026c900b006ce44fb7d3esi944958pfw.394.2023.12.05.11.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 11:55:02 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 01E118145546; Tue, 5 Dec 2023 11:55:00 -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 S232214AbjLETyp convert rfc822-to-8bit (ORCPT + 99 others); Tue, 5 Dec 2023 14:54:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjLETyn (ORCPT ); Tue, 5 Dec 2023 14:54:43 -0500 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD7FA5; Tue, 5 Dec 2023 11:54:49 -0800 (PST) Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-1fb155ca04bso581560fac.0; Tue, 05 Dec 2023 11:54:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701806089; x=1702410889; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MPGxsQoxPpHlL6Ppz0lS+ug6RWxWQAf1JLFDoILOKxk=; b=lv+OiBl5zo7w3ILusbHF0+pFabQAoBIz+oIC4vI4lR3hfRiD5QV9fBr1Ka5VYlRnNv cQIYZdV59OeMXaUSaZawvGN8qWlTLk3nMpca4XGDj1I3Sgi9jHlTS++76lIc6A4idwcJ iWKrCUrCdOFf7Srek8tc8Hsni1b950FcifPKCasDDs2tZZPGPguj4lbgmTjoXApDb1Yh q4l/uwguMBUK7dG9ZEDvYaHQZ1ZnjwPPE0xqhHFMVnB5rEl8g4kewPEqGIvZGjlp9T1z cOBUmJL5GkEMZ3fhcpgGDzLj9kFaBSAD41jNundsQU6NguUHTN5mzOEVy1XBFLRFRqdg EVdA== X-Gm-Message-State: AOJu0YyuxJS9BJ8oq2r3+bPKmDI373ykWk27iog9SW24mfyoYeOix6tD jd+m7GG5oFI4dODi4dd+DCYWEX5pwQPAnSvsFFg= X-Received: by 2002:a05:6870:75cd:b0:1fb:136e:fa93 with SMTP id de13-20020a05687075cd00b001fb136efa93mr12559032oab.0.1701806089143; Tue, 05 Dec 2023 11:54:49 -0800 (PST) MIME-Version: 1.0 References: <20231201123205.1996790-1-lukasz.luba@arm.com> In-Reply-To: <20231201123205.1996790-1-lukasz.luba@arm.com> From: "Rafael J. Wysocki" Date: Tue, 5 Dec 2023 20:54:38 +0100 Message-ID: Subject: Re: [PATCH] powercap: DTPM: Fix the missing cpufreq_cpu_put() calls To: Lukasz Luba Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, rafael@kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=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]); Tue, 05 Dec 2023 11:55:00 -0800 (PST) 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!