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

From: Baolin Wang
Date: Mon Jul 10 2023 - 06:07:21 EST




On 7/10/2023 4:03 PM, Chunyan Zhang wrote:
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@xxxxxxxxxx>

LGTM.
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>

---
drivers/tty/serial/sprd_serial.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

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;
}