[PATCH 1/2] serial: pic32_uart: do not free an IRQ that failed to be requested
From: Arina Kharlamova via B4 Relay
Date: Mon Nov 30 2026 - 17:57:38 EST
From: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>
When one of the three request_irq() calls in pic32_uart_startup()
fails, the error path jumps to the label that frees that same IRQ:
out_f after the fault IRQ, out_r after the RX IRQ and out_t after the
TX IRQ. free_irq() then finds no action for the port and warns
"Trying to free already-free IRQ".
Jump past the free_irq() of the IRQ that was not requested and only
free its name.
Fixes: 157b9394709e ("serial: pic32_uart: Add PIC32 UART driver")
Signed-off-by: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>
---
drivers/tty/serial/pic32_uart.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c
index a645b646bf8d..6c8874e50fa4 100644
--- a/drivers/tty/serial/pic32_uart.c
+++ b/drivers/tty/serial/pic32_uart.c
@@ -498,7 +498,7 @@ static int pic32_uart_startup(struct uart_port *port)
dev_err(port->dev, "%s: request irq(%d) err! ret:%d name:%s\n",
__func__, sport->irq_fault, ret,
pic32_uart_type(port));
- goto out_f;
+ goto out_f_name;
}
sport->irq_rx_name = kasprintf(GFP_KERNEL, "%s%d-rx",
@@ -516,7 +516,7 @@ static int pic32_uart_startup(struct uart_port *port)
dev_err(port->dev, "%s: request irq(%d) err! ret:%d name:%s\n",
__func__, sport->irq_rx, ret,
pic32_uart_type(port));
- goto out_r;
+ goto out_r_name;
}
sport->irq_tx_name = kasprintf(GFP_KERNEL, "%s%d-tx",
@@ -557,13 +557,14 @@ static int pic32_uart_startup(struct uart_port *port)
return 0;
out_t:
- free_irq(sport->irq_tx, port);
kfree(sport->irq_tx_name);
out_r:
free_irq(sport->irq_rx, port);
+out_r_name:
kfree(sport->irq_rx_name);
out_f:
free_irq(sport->irq_fault, port);
+out_f_name:
kfree(sport->irq_fault_name);
out_disable_clk:
clk_disable_unprepare(sport->clk);
--
Git-157)