Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ffe56619 authored by Chandana Kishori Chiluveru's avatar Chandana Kishori Chiluveru
Browse files

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.

Also check for GENI active state before stopping secondary engine in
earlyconsole stage.

Change-Id: Ibda592b375d14ba0c23c4b99223006b1fa53c211
Signed-off-by: default avatarChandana Kishori Chiluveru <cchiluve@codeaurora.org>
parent 7234d852
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -2116,10 +2116,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;
@@ -2647,6 +2643,12 @@ static void msm_geni_serial_cancel_rx(struct uart_port *uport)
	unsigned int irq_status;
	u32 rx_fifo_status;
	u32 rx_fifo_wc;
	u32 geni_status;

	geni_status = geni_read_reg_nolog(uport->membase, SE_GENI_STATUS);
	/* Possible thats stop rx is already done from UEFI end */
	if (!(geni_status & S_GENI_CMD_ACTIVE))
		return;

	geni_cancel_s_cmd(uport->membase);
	/* Ensure this goes through before polling. */
@@ -3229,6 +3231,11 @@ 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);