Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH] serial: rp2: remove ports on IRQ request failure in probe
@ 2026-11-25  8:40 Jiri Slaby (SUSE)
  2026-11-25  8:43 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Jiri Slaby (SUSE) @ 2026-11-25  8:40 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, Jiri Slaby (SUSE), Claude Opus 5.5, Kevin Cernekee,
	stable

Since commit 016002848c82 ("serial: rp2: use 'request_firmware' instead
of 'request_firmware_nowait'"), rp2_probe() loads the firmware and
registers all the UART ports (via rp2_load_firmware()) before requesting
the IRQ. But if devm_request_irq() fails, probe just returns the error
and leaves the ports registered with the serial core.

rp2_remove() is not called for a failed probe, so the ports stay
registered, pointing to a card whose devm-managed memory (card->ports
included) and iomaps are freed. Any later access to the tty devices
then results in a use-after-free.

Call rp2_remove_ports() when the IRQ request fails.

Fixes: 016002848c82 ("serial: rp2: use 'request_firmware' instead of 'request_firmware_nowait'")
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: <stable@vger.kernel.org>
---
 drivers/tty/serial/rp2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/rp2.c b/drivers/tty/serial/rp2.c
index 158b06424b56..f82270bf7060 100644
--- a/drivers/tty/serial/rp2.c
+++ b/drivers/tty/serial/rp2.c
@@ -755,9 +755,9 @@ static int rp2_probe(struct pci_dev *pdev,
 	rc = devm_request_irq(&pdev->dev, pdev->irq, rp2_uart_interrupt,
 			      IRQF_SHARED, DRV_NAME, card);
 	if (rc)
-		return rc;
+		rp2_remove_ports(card);
 
-	return 0;
+	return rc;
 }
 
 static void rp2_remove(struct pci_dev *pdev)
-- 
2.56.1


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

end of thread, other threads:[~2026-11-25  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  8:40 [PATCH] serial: rp2: remove ports on IRQ request failure in probe Jiri Slaby (SUSE)
2026-11-25  8:43 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox