mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
serial: altera_jtaguart: handle uart_add_one_port() failures
altera_jtaguart_probe() maps the register window before registering the
UART port, but it ignores failures from uart_add_one_port(). If port
registration fails, probe still returns success and the mapping remains
live until a later remove path that is not part of probe failure cleanup.
Return the uart_add_one_port() error and unmap the register window on
that failure path.
This issue was identified during our ongoing static-analysis research while
reviewing kernel code.
Fixes: 5bcd601049 ("serial: Add driver for the Altera JTAG UART")
Cc: stable <stable@kernel.org>
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Link: https://patch.msgid.link/20260512065837.79528-1-mhun512@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
452d6fa37a
commit
ea66be25f0
|
|
@ -379,6 +379,7 @@ static int altera_jtaguart_probe(struct platform_device *pdev)
|
|||
struct resource *res_mem;
|
||||
int i = pdev->id;
|
||||
int irq;
|
||||
int ret;
|
||||
|
||||
/* -1 emphasizes that the platform must have one port, no .N suffix */
|
||||
if (i == -1)
|
||||
|
|
@ -418,7 +419,11 @@ static int altera_jtaguart_probe(struct platform_device *pdev)
|
|||
port->flags = UPF_BOOT_AUTOCONF;
|
||||
port->dev = &pdev->dev;
|
||||
|
||||
uart_add_one_port(&altera_jtaguart_driver, port);
|
||||
ret = uart_add_one_port(&altera_jtaguart_driver, port);
|
||||
if (ret) {
|
||||
iounmap(port->membase);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user