From 0c8f1050dae3c28e0e53dc52fbc4c856bb56e6ce Mon Sep 17 00:00:00 2001 From: Somesh Dey Date: Tue, 8 Oct 2024 13:48:56 +0530 Subject: [PATCH] serial: msm_geni_serial: Return error in probe upon memory allocation failure Return error in probe when memory allocation fails for rx_fifo. Change-Id: Ic1d784dca2ffeb3aeaa71879d5538294df9de9ca Signed-off-by: Somesh Dey --- drivers/tty/serial/msm_geni_serial.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/msm_geni_serial.c b/drivers/tty/serial/msm_geni_serial.c index 6f1b236134c8..86430e526f13 100644 --- a/drivers/tty/serial/msm_geni_serial.c +++ b/drivers/tty/serial/msm_geni_serial.c @@ -5475,10 +5475,14 @@ static int msm_geni_serial_port_init(struct platform_device *pdev, if (dev_port->is_console) { dev_port->handle_rx = handle_rx_console; dev_port->rx_fifo = devm_kzalloc(uport->dev, sizeof(u32), GFP_KERNEL); + if (!dev_port->rx_fifo) + return -ENOMEM; } else { dev_port->handle_rx = handle_rx_hs; dev_port->rx_fifo = devm_kzalloc(uport->dev, sizeof(dev_port->rx_fifo_depth * sizeof(u32)), GFP_KERNEL); + if (!dev_port->rx_fifo) + return -ENOMEM; if (dev_port->pm_auto_suspend_disable) { pm_runtime_set_active(&pdev->dev); pm_runtime_forbid(&pdev->dev);