diff mbox series

[2/2] serial: sprd: Fix DMA buffer leak issue

Message ID 20230710080348.4137875-2-chunyan.zhang@unisoc.com
State New
Headers show
Series [1/2] serial: sprd: Assign sprd_port after initialized to avoid wrong access | expand

Commit Message

Chunyan Zhang July 10, 2023, 8:03 a.m. UTC
Release DMA buffer when _probe() returns fail to avoid memory leak.

Fixes: f4487db58eb7 ("serial: sprd: Add DMA mode support")
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
 drivers/tty/serial/sprd_serial.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 942808517393..e1f11382fc39 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -1203,7 +1203,7 @@  static int sprd_probe(struct platform_device *pdev)
 		ret = uart_register_driver(&sprd_uart_driver);
 		if (ret < 0) {
 			pr_err("Failed to register SPRD-UART driver\n");
-			return ret;
+			goto free_rx_buf;
 		}
 	}
 	sprd_ports_num++;
@@ -1222,6 +1222,8 @@  static int sprd_probe(struct platform_device *pdev)
 	sprd_port[index] = NULL;
 	sprd_ports_num--;
 	uart_unregister_driver(&sprd_uart_driver);
+free_rx_buf:
+	sprd_rx_free_buf(sport);
 	return ret;
 }