[PATCH] tty: serial: fsl_lpuart: fix DMA mapping

From: Michael Walle
Date: Fri Mar 06 2020 - 16:44:31 EST


The analysis report is as follows for function lpuart_dma_rx_free in
source drivers/tty/serial/fsl_lpuart.c :

var_compare_op: Comparing chan to null implies that chan might be null.

1234 if (chan)
1235 dmaengine_terminate_all(chan);
1236

Dereference after null check (FORWARD_NULL)
var_deref_op: Dereferencing null pointer chan.

1237 dma_unmap_sg(chan->device->dev, &sport->rx_sgl, 1,
DMA_FROM_DEVICE);

The check for chan being null implies it is may be null, however, the
call to dma_unmap_sg dereferences chan which leads to a null pointer
dereference issue.

Colin