mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/3] mfd: tps65217: Handle IRQ initialization errors
@ 2026-09-04  6:34 Жамбакиев Радий Рикардинович
  2026-09-04  6:34 ` [PATCH v3 1/3] mfd: tps65217: Fix NULL pointer dereference on IRQ init failure Жамбакиев Радий Рикардинович
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Жамбакиев Радий Рикардинович @ 2026-09-04  6:34 UTC (permalink / raw)
  To: Aaro Koskinen
  Cc: Жамбакиев
	Радий
	Рикардинович,
	Andreas Kemnade, Kevin Hilman, Roger Quadros, Tony Lindgren,
	Lee Jones, Marcin Niestroj, Grygorii Strashko, linux-omap, mfd,
	linux-kernel, lvc-project

From: Radiy Zhambakiev <r.zhambakiev@prosoftsystems.ru>

The TPS65217 MFD driver does not validate the outcome of IRQ
initialisation: tps65217_probe() ignores the return value of
tps65217_irq_init(), so a failed irq_domain creation leaves the
driver bound with a NULL tps->irq_domain and the remove callback
oopses, and a failed write of the interrupt mask leaves the software
mask out of sync with the hardware.

On top of that the irq_domain is torn down in the wrong order: the
remove callback disposes the mappings and removes the domain before
the MFD children are unbound, so children that requested interrupts
(e.g. tps65217-charger) release virtual IRQs whose descriptors are
already disposed, and on probe failure the domain is leaked with its
host_data pointing to freed memory. The enable_irq_wake() in probe
is never balanced.

This series plugs the probe error paths and moves the domain and
wake-up teardown into devres, registered right after the domain is
created. Devres actions are released in reverse order of
registration, so on both removal and probe failure the MFD children
release their IRQs first, then the parent interrupt is freed and its
thread stopped, and only then is the domain removed.

Changes since v2:
 - Replace "Fix irq_domain leak and use-after-free on probe failure"
   with "Use devres for IRQ domain and wake teardown". The domain
   teardown is a devres action registered before the parent
   interrupt, so it is released after devm_request_threaded_irq()
   has freed the interrupt and stopped the threaded handler. This
   closes the window flagged in review, in which a late interrupt
   could run the handler against a removed or NULL irq_domain, and
   makes the manual disable_irq()/synchronize_irq() on the error
   path unnecessary.
 - Drop "Fix NULL pointer dereference in remove callback", now
   obsolete: the remove callback is gone.
 - Added "From" to the body of the patches to avoid checkpatch.pl
   email name mismatch error.

Radiy Zhambakiev (3):
  mfd: tps65217: Fix NULL pointer dereference on IRQ init failure
  mfd: tps65217: Check return value when masking interrupt sources
  mfd: tps65217: Use devres for IRQ domain and wake teardown

 drivers/mfd/tps65217.c | 81 +++++++++++++++++++++++++++++++-----------
 1 file changed, 60 insertions(+), 21 deletions(-)

-- 
2.55.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-16 14:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-04  6:34 [PATCH v3 0/3] mfd: tps65217: Handle IRQ initialization errors Жамбакиев Радий Рикардинович
2026-09-04  6:34 ` [PATCH v3 1/3] mfd: tps65217: Fix NULL pointer dereference on IRQ init failure Жамбакиев Радий Рикардинович
2026-09-04  6:34 ` [PATCH v3 2/3] mfd: tps65217: Check return value when masking interrupt sources Жамбакиев Радий Рикардинович
2026-09-16 14:06   ` Lee Jones
2026-09-04  6:34 ` [PATCH v3 3/3] mfd: tps65217: Use devres for IRQ domain and wake teardown Жамбакиев Радий Рикардинович
2026-09-16 14:37   ` Lee Jones

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®