serial: liteuart: fix return value check in liteuart_probe()
authorWei Yongjun <weiyongjun1@huawei.com>
Fri, 5 Mar 2021 03:49:29 +0000 (03:49 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Mar 2021 08:34:10 +0000 (09:34 +0100)
In case of error, the function devm_platform_get_and_ioremap_resource()
returns ERR_PTR() and never returns NULL. The NULL test in the return
value check should be replaced with IS_ERR().

Fixes: 1da81e5562fa ("drivers/tty/serial: add LiteUART driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Link: https://lore.kernel.org/r/20210305034929.3234352-1-weiyongjun1@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/liteuart.c

index 64842f3..0b06770 100644 (file)
@@ -270,8 +270,8 @@ static int liteuart_probe(struct platform_device *pdev)
 
        /* get membase */
        port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
-       if (!port->membase)
-               return -ENXIO;
+       if (IS_ERR(port->membase))
+               return PTR_ERR(port->membase);
 
        /* values not from device tree */
        port->dev = &pdev->dev;