Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH] serial: altera_jtaguart: handle uart_add_one_port() failures
@ 2026-04-28  6:44 Myeonghun Pak
  2026-05-11 15:15 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-04-28  6:44 UTC (permalink / raw)
  To: Tobias Klauser, Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, linux-kernel, Myeonghun Pak, Ijae Kim

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.

Fixes: 5bcd601049c6 ("serial: Add driver for the Altera JTAG UART")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/tty/serial/altera_jtaguart.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index d47a62d1c9..15588b6dc3 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -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,12 @@ 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);
+		port->membase = NULL;
+		return ret;
+	}
 
 	return 0;
 }
-- 
2.51.0

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

* Re: [PATCH] serial: altera_jtaguart: handle uart_add_one_port() failures
  2026-04-28  6:44 [PATCH] serial: altera_jtaguart: handle uart_add_one_port() failures Myeonghun Pak
@ 2026-05-11 15:15 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-05-11 15:15 UTC (permalink / raw)
  To: Myeonghun Pak
  Cc: Tobias Klauser, Jiri Slaby, linux-serial, linux-kernel, Ijae Kim

On Tue, Apr 28, 2026 at 03:44:57PM +0900, Myeonghun Pak wrote:
> 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.
> 
> Fixes: 5bcd601049c6 ("serial: Add driver for the Altera JTAG UART")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>  drivers/tty/serial/altera_jtaguart.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
> index d47a62d1c9..15588b6dc3 100644
> --- a/drivers/tty/serial/altera_jtaguart.c
> +++ b/drivers/tty/serial/altera_jtaguart.c
> @@ -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,12 @@ 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);
> +		port->membase = NULL;

Why is membase being set to NULL, that should not be needed, right?

How was this tested?

thanks,

greg k-h

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

end of thread, other threads:[~2026-05-11 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28  6:44 [PATCH] serial: altera_jtaguart: handle uart_add_one_port() failures Myeonghun Pak
2026-05-11 15:15 ` Greg Kroah-Hartman

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