From 1c701bd680fcca1fc8c511f44868953d2b94fcdd Mon Sep 17 00:00:00 2001 From: Akash Asthana Date: Wed, 17 Jun 2020 10:51:01 +0530 Subject: [PATCH] serial: msm-geni-serial: Fix possible null pointer access with handle_rx Some customers are using UART node in UFFI for console and using the same node for HSUART in kernel but not as console. In this scenario there is a possibility for null pointer access with handle_rx while trying to stop secondary sequencer. This change will move handle_rx initialization from port_startup to probe function. This will help to avoid null pointer access issues. Change-Id: Ibda592b375d14ba0c23c4b99223006b1fa53c211 Signed-off-by: Chandana Kishori Chiluveru Signed-off-by: Akash Asthana --- drivers/tty/serial/msm_geni_serial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/msm_geni_serial.c b/drivers/tty/serial/msm_geni_serial.c index 8ae1ca016ecf..ed8e9f5bc806 100644 --- a/drivers/tty/serial/msm_geni_serial.c +++ b/drivers/tty/serial/msm_geni_serial.c @@ -2127,10 +2127,6 @@ static int msm_geni_serial_port_setup(struct uart_port *uport) SE_GENI_RX_PACKING_CFG0); geni_write_reg_nolog(cfg1, uport->membase, SE_GENI_RX_PACKING_CFG1); - msm_port->handle_rx = handle_rx_hs; - msm_port->rx_fifo = devm_kzalloc(uport->dev, - sizeof(msm_port->rx_fifo_depth * sizeof(u32)), - GFP_KERNEL); if (!msm_port->rx_fifo) { ret = -ENOMEM; goto exit_portsetup; @@ -3062,6 +3058,10 @@ static int msm_geni_serial_probe(struct platform_device *pdev) dev_port->rx_fifo = devm_kzalloc(uport->dev, sizeof(u32), GFP_KERNEL); } 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); pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 150); pm_runtime_use_autosuspend(&pdev->dev);