diff mbox series

[-next] n64: fix return value check in n64cart_probe()

Message ID 20210223140104.1743541-1-weiyongjun1@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] n64: fix return value check in n64cart_probe() | expand

Commit Message

Wei Yongjun Feb. 23, 2021, 2:01 p.m. UTC
In case of error, the function devm_platform_ioremap_resource()
returns ERR_PTR() and never returns NULL. The NULL test in the
return value check should be replaced with IS_ERR().

Fixes: d9b2a2bbbb4d ("block: Add n64 cart driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/block/n64cart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lauri Kasanen Feb. 23, 2021, 2:56 p.m. UTC | #1
On Tue, 23 Feb 2021 14:01:04 +0000
Wei Yongjun <weiyongjun1@huawei.com> wrote:

> In case of error, the function devm_platform_ioremap_resource()
> returns ERR_PTR() and never returns NULL. The NULL test in the
> return value check should be replaced with IS_ERR().
>
> Fixes: d9b2a2bbbb4d ("block: Add n64 cart driver")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/block/n64cart.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/n64cart.c b/drivers/block/n64cart.c
> index 47bdf324e962..84a0f8d0be29 100644
> --- a/drivers/block/n64cart.c
> +++ b/drivers/block/n64cart.c
> @@ -129,8 +129,8 @@ static int __init n64cart_probe(struct platform_device *pdev)
>  	}
>
>  	reg_base = devm_platform_ioremap_resource(pdev, 0);
> -	if (!reg_base)
> -		return -EINVAL;
> +	if (IS_ERR(reg_base))
> +		return ERR_PTR(reg_base);
>
>  	disk = alloc_disk(0);
>  	if (!disk)
>

Reviewed-by: Lauri Kasanen <cand@gmx.com>

- Lauri
Chaitanya Kulkarni Feb. 23, 2021, 7:32 p.m. UTC | #2
On 2/23/21 05:55, Wei Yongjun wrote:
> In case of error, the function devm_platform_ioremap_resource()
> returns ERR_PTR() and never returns NULL. The NULL test in the
> return value check should be replaced with IS_ERR().
>
> Fixes: d9b2a2bbbb4d ("block: Add n64 cart driver")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
diff mbox series

Patch

diff --git a/drivers/block/n64cart.c b/drivers/block/n64cart.c
index 47bdf324e962..84a0f8d0be29 100644
--- a/drivers/block/n64cart.c
+++ b/drivers/block/n64cart.c
@@ -129,8 +129,8 @@  static int __init n64cart_probe(struct platform_device *pdev)
 	}
 
 	reg_base = devm_platform_ioremap_resource(pdev, 0);
-	if (!reg_base)
-		return -EINVAL;
+	if (IS_ERR(reg_base))
+		return ERR_PTR(reg_base);
 
 	disk = alloc_disk(0);
 	if (!disk)