diff mbox series

cxl/region: Fix IS_ERR() vs NULL check

Message ID Yuo65lq2WtfdGJ0X@kili
State Accepted
Commit 9fd2cf4d6fba8253efa62ba45f623ab7f09df12d
Headers show
Series cxl/region: Fix IS_ERR() vs NULL check | expand

Commit Message

Dan Carpenter Aug. 3, 2022, 9:07 a.m. UTC
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>
---
 drivers/cxl/pmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Aug. 3, 2022, 3:43 p.m. UTC | #1
On Wed, 3 Aug 2022 12:07:50 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> 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>
LGTM

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/cxl/pmem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
> index e69f99a0747d..7dc0a2fa1a6b 100644
> --- a/drivers/cxl/pmem.c
> +++ b/drivers/cxl/pmem.c
> @@ -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;
>  	}
>
Dan Williams Aug. 5, 2022, 12:23 a.m. UTC | #2
Dan Carpenter wrote:
> 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>
> ---
>  drivers/cxl/pmem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
> index e69f99a0747d..7dc0a2fa1a6b 100644
> --- a/drivers/cxl/pmem.c
> +++ b/drivers/cxl/pmem.c
> @@ -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;

Thanks, applied.
diff mbox series

Patch

diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
index e69f99a0747d..7dc0a2fa1a6b 100644
--- a/drivers/cxl/pmem.c
+++ b/drivers/cxl/pmem.c
@@ -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;
 	}