* [PATCH] stm: Fix potential policy leak after device unregistration
@ 2026-11-13 14:06 Guangshuo Li
0 siblings, 0 replies; only message in thread
From: Guangshuo Li @ 2026-11-13 14:06 UTC (permalink / raw)
To: Alexander Shishkin, Maxime Coquelin, Alexandre Torgue
Cc: linux-stm32, linux-arm-kernel, linux-kernel, stable
A policy can outlive its STM device. When that happens, device teardown
has already cleared policy->stm and stp_policy_release() returns without
freeing the policy.
Only skip unbinding an already unbound policy; always free its memory.
This issue was found by our static analysis tool under development.
Fixes: 4c127fd16e6b ("stm class: Fix locking in unbinding policy path")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
drivers/hwtracing/stm/policy.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
index fabaf4b14889..ec0c9f4d693e 100644
--- a/drivers/hwtracing/stm/policy.c
+++ b/drivers/hwtracing/stm/policy.c
@@ -354,12 +354,11 @@ static void stp_policy_release(struct config_item *item)
struct stm_device *stm = policy->stm;
/* a policy *can* be unbound and still exist in configfs tree */
- if (!stm)
- return;
-
- mutex_lock(&stm->policy_mutex);
- stp_policy_unbind(policy);
- mutex_unlock(&stm->policy_mutex);
+ if (stm) {
+ mutex_lock(&stm->policy_mutex);
+ stp_policy_unbind(policy);
+ mutex_unlock(&stm->policy_mutex);
+ }
kfree(policy);
}
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-13 14:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 14:06 [PATCH] stm: Fix potential policy leak after device unregistration Guangshuo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®