staging: mt7621-eth: fix return value check in mt7621_gsw_probe()
authorWei Yongjun <weiyongjun1@huawei.com>
Mon, 14 May 2018 18:14:25 +0000 (11:14 -0700)
committerJohn Crispin <john@phrozen.org>
Tue, 15 May 2018 04:46:08 +0000 (06:46 +0200)
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: f079b6406348 ("staging: mt7621-eth: add gigabit switch driver (GSW)")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
target/linux/ramips/files-4.14/drivers/net/ethernet/mtk/esw_rt3050.c
target/linux/ramips/files-4.14/drivers/net/ethernet/mtk/gsw_mt7620.c
target/linux/ramips/files-4.14/drivers/net/ethernet/mtk/gsw_mt7621.c

index 6cad5856cd36c4225e60660fda05d1ae8dd17366..816c588dd7f2db40c8e10c4d7f76b4c9cf90fab8 100644 (file)
@@ -1358,8 +1358,8 @@ static int esw_probe(struct platform_device *pdev)
        esw->dev = &pdev->dev;
        esw->irq = irq_of_parse_and_map(np, 0);
        esw->base = devm_ioremap_resource(&pdev->dev, res);
-       if (!esw->base)
-               return -EADDRNOTAVAIL;
+       if (IS_ERR(esw->base))
+               return PTR_ERR(esw->base);
 
        port_map = of_get_property(np, "mediatek,portmap", NULL);
        if (port_map)
index 4093f09d419b9a6ab9029e2df38c89dc913b1c34..a4602c45868f4f8a68576d8857faa213960d2047 100644 (file)
@@ -215,8 +215,8 @@ static int mt7620_gsw_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        gsw->base = devm_ioremap_resource(&pdev->dev, res);
-       if (!gsw->base)
-               return -EADDRNOTAVAIL;
+       if (IS_ERR(gsw->base))
+               return PTR_ERR(gsw->base);
 
        gsw->dev = &pdev->dev;
 
index 9d5fe6efeedd0889e2829754a2f48da7cce5629c..89be23900738095a8180532d5dd7e585f01bb7c4 100644 (file)
@@ -245,8 +245,8 @@ static int mt7621_gsw_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        gsw->base = devm_ioremap_resource(&pdev->dev, res);
-       if (!gsw->base)
-               return -EADDRNOTAVAIL;
+       if (IS_ERR(gsw->base))
+               return PTR_ERR(gsw->base);
 
        gsw->dev = &pdev->dev;
        gsw->irq = platform_get_irq(pdev, 0);