From: Alexander Stein alexander.stein@ew.tq-group.com
[ Upstream commit 57bf2a312ab2d0bc8ee0f4e8a447fa94a2fc877d ]
The IRQ domain is (optionally) added during stmpe_probe, but never removed. Add the call to stmpe_remove.
Signed-off-by: Alexander Stein alexander.stein@ew.tq-group.com Link: https://lore.kernel.org/r/20250725070752.338376-1-alexander.stein@ew.tq-grou... Signed-off-by: Lee Jones lee@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- What changed - Adds missing cleanup in `stmpe_remove()` to tear down the IRQ domain: `drivers/mfd/stmpe.c:1486` - New lines: `if (stmpe->domain) irq_domain_remove(stmpe->domain);` - The IRQ domain is created in probe via `irq_domain_create_simple(...)` in `stmpe_irq_init()`: `drivers/mfd/stmpe.c:1222` - The domain is passed to children via MFD core (`mfd_add_devices(..., stmpe->domain)`), so it persists beyond probe: `drivers/mfd/stmpe.c:1295`
- Why it matters - Bug: Resource leak and stale IRQ domain on device removal/module unload. The driver creates an IRQ domain during probe but never removes it, leaving mappings/structures alive after unbind/unload. - User impact: Rebind/unload scenarios can accumulate leaked IRQ resources; at minimum this is a memory/resource leak, at worst it risks stale references in debug/introspection paths.
- Scope and risk - Minimal change (3 LOC), confined to removal path in `stmpe_remove()`. - No functional/architectural changes; no runtime behavior changes while device is active. - Standard API usage: `irq_domain_remove()` is the canonical teardown for domains created with `irq_domain_create_*()`. - Children devices don’t require `stmpe->domain` during removal; `mfd_remove_devices()` triggers child driver unbinds using Linux IRQ numbers, and `free_irq()` does not depend on the domain object. So calling `irq_domain_remove()` at the start of `stmpe_remove()` is safe.
- Historical/context checks - Domain creation present: `stmpe_irq_init()` uses `irq_domain_create_simple(...)`: `drivers/mfd/stmpe.c:1222`. - MFD children use the domain only at registration time for IRQ mapping: `mfd_add_devices(..., stmpe->domain)`: `drivers/mfd/stmpe.c:1295`. - Upstream commit already merged (57bf2a312ab2d), indicating maintainer review and acceptance.
- Stable backport criteria - Fixes a real bug (resource leak on driver removal) that can affect users in unbind/rebind or module unload workflows. - Small, self-contained, and low risk. - No new features or architectural changes. - Touches an MFD driver only; not a critical core subsystem. - No external dependencies beyond long‑standing IRQ domain APIs.
- Notes - This commit doesn’t address probe-failure paths (domain created then probe fails before `stmpe_remove()`); that’s a separate improvement, but not required for this backport. - If any stable branch differs in function signatures/locations, the change still trivially adapts: just add the `irq_domain_remove(stmpe->domain)` in that branch’s `stmpe_remove()` implementation.
drivers/mfd/stmpe.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 819d19dc9b4a9..e1165f63aedae 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -1485,6 +1485,9 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)
void stmpe_remove(struct stmpe *stmpe) { + if (stmpe->domain) + irq_domain_remove(stmpe->domain); + if (!IS_ERR(stmpe->vio) && regulator_is_enabled(stmpe->vio)) regulator_disable(stmpe->vio); if (!IS_ERR(stmpe->vcc) && regulator_is_enabled(stmpe->vcc))