public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [tty/serial] 8250_acorn: Add error handling in serial_card_probe
@ 2023-11-29 11:52 Haoran Liu
  2023-11-29 13:34 ` Greg KH
  2023-11-29 14:40 ` Hugo Villeneuve
  0 siblings, 2 replies; 3+ messages in thread
From: Haoran Liu @ 2023-11-29 11:52 UTC (permalink / raw)
  To: gregkh; +Cc: jirislaby, linux-serial, linux-kernel, Haoran Liu

This patch adds error handling to the serial_card_probe
function in drivers/tty/serial/8250/8250_acorn.c. The
serial8250_register_8250_port call within this function
previously lacked proper handling for failure scenarios.

Signed-off-by: Haoran Liu <liuhaoran14@163.com>
---
 drivers/tty/serial/8250/8250_acorn.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_acorn.c b/drivers/tty/serial/8250/8250_acorn.c
index 758c4aa203ab..378ae6936028 100644
--- a/drivers/tty/serial/8250/8250_acorn.c
+++ b/drivers/tty/serial/8250/8250_acorn.c
@@ -43,6 +43,7 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
 	struct uart_8250_port uart;
 	unsigned long bus_addr;
 	unsigned int i;
+	int ret;
 
 	info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL);
 	if (!info)
@@ -72,6 +73,14 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
 		uart.port.mapbase = bus_addr + type->offset[i];
 
 		info->ports[i] = serial8250_register_8250_port(&uart);
+		if (IS_ERR(info->ports[i])) {
+			ret = PTR_ERR(info->ports[i]);
+			while (i--)
+				serial8250_unregister_port(info->ports[i]);
+
+			kfree(info);
+			return ret;
+		}
 	}
 
 	return 0;
-- 
2.17.1


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

end of thread, other threads:[~2023-11-29 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-29 11:52 [PATCH] [tty/serial] 8250_acorn: Add error handling in serial_card_probe Haoran Liu
2023-11-29 13:34 ` Greg KH
2023-11-29 14:40 ` Hugo Villeneuve

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