From: Sumeet Pawnikar <sumeet4linux@gmail.com>
To: rafael@kernel.org, linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, sumeet4linux@gmail.com
Subject: [PATCH] powercap: intel_rapl_tpmi: Handle PMU registration failure during probe
Date: Sat, 16 May 2026 00:12:50 +0530 [thread overview]
Message-ID: <20260515184250.228062-1-sumeet4linux@gmail.com> (raw)
intel_rapl_tpmi_probe() invokes rapl_package_add_pmu() but it ignores
the return value, so a PMU registration failure may leave the driver
reporting probe success despite the PMU being absent, with no log
trace. Worse case scenario, the previously-added RAPL package would
not be torn down.
Add check for the return value, log the failure, undo the package
addition with rapl_remove_package() and fail the probe.
Signed-off-by: Sumeet Pawnikar <sumeet4linux@gmail.com>
---
drivers/powercap/intel_rapl_tpmi.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/powercap/intel_rapl_tpmi.c b/drivers/powercap/intel_rapl_tpmi.c
index 7f41491d9cd1..8bc95310b542 100644
--- a/drivers/powercap/intel_rapl_tpmi.c
+++ b/drivers/powercap/intel_rapl_tpmi.c
@@ -414,7 +414,14 @@ static int intel_rapl_tpmi_probe(struct auxiliary_device *auxdev,
goto err;
}
- rapl_package_add_pmu(trp->rp);
+ ret = rapl_package_add_pmu(trp->rp);
+ if (ret) {
+ dev_err(&auxdev->dev, "Failed to add RAPL PMU for Package%d, %d\n",
+ info->package_id, ret);
+ rapl_remove_package(trp->rp);
+ trp->rp = NULL;
+ goto err;
+ }
auxiliary_set_drvdata(auxdev, trp);
--
2.43.0
reply other threads:[~2026-05-15 18:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260515184250.228062-1-sumeet4linux@gmail.com \
--to=sumeet4linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox