EDAC/sifive: Fix return value check in ecc_register()
authorWei Yongjun <weiyongjun1@huawei.com>
Wed, 15 Jan 2020 15:03:03 +0000 (15:03 +0000)
committerBorislav Petkov <bp@suse.de>
Fri, 17 Jan 2020 00:37:51 +0000 (01:37 +0100)
In case of error, the function edac_device_alloc_ctl_info() returns a
NULL pointer, not ERR_PTR(). Replace the IS_ERR() test in the return
value check with a NULL test.

Fixes: 91abaeaaff35 ("EDAC/sifive: Add EDAC platform driver for SiFive SoCs")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200115150303.112627-1-weiyongjun1@huawei.com
drivers/edac/sifive_edac.c

index 413cdb4a591db1758d799277646bcce6601c31f1..bb9ceeaf29bf9112e9b59c46051b8b5ffc5ef0fd 100644 (file)
@@ -54,8 +54,8 @@ static int ecc_register(struct platform_device *pdev)
        p->dci = edac_device_alloc_ctl_info(0, "sifive_ecc", 1, "sifive_ecc",
                                            1, 1, NULL, 0,
                                            edac_device_alloc_index());
-       if (IS_ERR(p->dci))
-               return PTR_ERR(p->dci);
+       if (!p->dci)
+               return -ENOMEM;
 
        p->dci->dev = &pdev->dev;
        p->dci->mod_name = "Sifive ECC Manager";