Skip to content

Commit 447ee15

Browse files
Yang Yinglianggregkh
authored andcommitted
tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
It will cause null-ptr-deref when using 'res', if platform_get_resource() returns NULL, so move using 'res' after devm_ioremap_resource() that will check it to avoid null-ptr-deref. And use devm_platform_get_and_ioremap_resource() to simplify code. Fixes: 5930cb3 ("serial: driver for Conexant Digicolor USART") Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Baruch Siach <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 672c0c5 commit 447ee15

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/tty/serial/digicolor-usart.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
471471
if (IS_ERR(uart_clk))
472472
return PTR_ERR(uart_clk);
473473

474-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
475-
dp->port.mapbase = res->start;
476-
dp->port.membase = devm_ioremap_resource(&pdev->dev, res);
474+
dp->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
477475
if (IS_ERR(dp->port.membase))
478476
return PTR_ERR(dp->port.membase);
477+
dp->port.mapbase = res->start;
479478

480479
irq = platform_get_irq(pdev, 0);
481480
if (irq < 0)

0 commit comments

Comments
 (0)