Skip to content

Commit 1575c08

Browse files
GustavoARSilvagregkh
authored andcommitted
tty: serial: 8250_mtk: Fix potential NULL pointer dereference
There is a potential NULL pointer dereference in case devm_kzalloc() fails and returns NULL. Fix this by adding a NULL check on data->dma This bug was detected with the help of Coccinelle. Fixes: 85b5c1d ("serial: 8250-mtk: add uart DMA support") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f17b5f0 commit 1575c08

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/tty/serial/8250/8250_mtk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p,
357357
if (dmacnt == 2) {
358358
data->dma = devm_kzalloc(&pdev->dev, sizeof(*data->dma),
359359
GFP_KERNEL);
360+
if (!data->dma)
361+
return -ENOMEM;
362+
360363
data->dma->fn = mtk8250_dma_filter;
361364
data->dma->rx_size = MTK_UART_RX_SIZE;
362365
data->dma->rxconf.src_maxburst = MTK_UART_RX_TRIGGER;

0 commit comments

Comments
 (0)