cxl/region: Fix IS_ERR() vs NULL check
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 3 Aug 2022 09:07:50 +0000 (12:07 +0300)
committerDan Williams <dan.j.williams@intel.com>
Fri, 5 Aug 2022 15:41:02 +0000 (08:41 -0700)
The nvdimm_pmem_region_create() function returns NULL on error.  It does
not return error pointers.

Fixes: 04ad63f086d1 ("cxl/region: Introduce cxl_pmem_region objects")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/Yuo65lq2WtfdGJ0X@kili
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/pmem.c

index e69f99a0747da67f4613b3338ea85f7f79533c93..7dc0a2fa1a6b612341576c0c5481d633bb1f0aa1 100644 (file)
@@ -525,8 +525,8 @@ static int cxl_pmem_region_probe(struct device *dev)
 
        cxlr_pmem->nd_region =
                nvdimm_pmem_region_create(cxl_nvb->nvdimm_bus, &ndr_desc);
-       if (IS_ERR(cxlr_pmem->nd_region)) {
-               rc = PTR_ERR(cxlr_pmem->nd_region);
+       if (!cxlr_pmem->nd_region) {
+               rc = -ENOMEM;
                goto err;
        }