All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: mlxbf: Fix the return check of devm_ioremapm and ioremap
@ 2020-11-11  3:27 Wang Xiaojun
  2020-11-13 22:49 ` Khalil Blaiech
  2020-12-02 15:37 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Wang Xiaojun @ 2020-11-11  3:27 UTC (permalink / raw)
  To: kblaiech; +Cc: linux-i2c

devm_ioremapm and ioremap may return NULL which cannot be checked
by IS_ERR.

Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
---
 drivers/i2c/busses/i2c-mlxbf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
index 33574d40ea9c..2fb0532d8a16 100644
--- a/drivers/i2c/busses/i2c-mlxbf.c
+++ b/drivers/i2c/busses/i2c-mlxbf.c
@@ -1258,9 +1258,9 @@ static int mlxbf_i2c_get_gpio(struct platform_device *pdev,
 		return -EFAULT;
 
 	gpio_res->io = devm_ioremap(dev, params->start, size);
-	if (IS_ERR(gpio_res->io)) {
+	if (!gpio_res->io) {
 		devm_release_mem_region(dev, params->start, size);
-		return PTR_ERR(gpio_res->io);
+		return -ENOMEM;
 	}
 
 	return 0;
@@ -1323,9 +1323,9 @@ static int mlxbf_i2c_get_corepll(struct platform_device *pdev,
 		return -EFAULT;
 
 	corepll_res->io = devm_ioremap(dev, params->start, size);
-	if (IS_ERR(corepll_res->io)) {
+	if (!corepll_res->io) {
 		devm_release_mem_region(dev, params->start, size);
-		return PTR_ERR(corepll_res->io);
+		return -ENOMEM;
 	}
 
 	return 0;
@@ -1717,9 +1717,9 @@ static int mlxbf_i2c_init_coalesce(struct platform_device *pdev,
 			return -EFAULT;
 
 		coalesce_res->io = ioremap(params->start, size);
-		if (IS_ERR(coalesce_res->io)) {
+		if (!coalesce_res->io) {
 			release_mem_region(params->start, size);
-			return PTR_ERR(coalesce_res->io);
+			return -ENOMEM;
 		}
 
 		priv->coalesce = coalesce_res;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] i2c: mlxbf: Fix the return check of devm_ioremapm and ioremap
  2020-11-11  3:27 [PATCH] i2c: mlxbf: Fix the return check of devm_ioremapm and ioremap Wang Xiaojun
@ 2020-11-13 22:49 ` Khalil Blaiech
  2020-12-02 15:37 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Khalil Blaiech @ 2020-11-13 22:49 UTC (permalink / raw)
  To: Wang Xiaojun; +Cc: linux-i2c



> devm_ioremapm and ioremap may return NULL which cannot be checked
> by IS_ERR.

devm_ioremap

> 
> Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> ---
>  drivers/i2c/busses/i2c-mlxbf.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
> index 33574d40ea9c..2fb0532d8a16 100644
> --- a/drivers/i2c/busses/i2c-mlxbf.c
> +++ b/drivers/i2c/busses/i2c-mlxbf.c
> @@ -1258,9 +1258,9 @@ static int mlxbf_i2c_get_gpio(struct
> platform_device *pdev,
>  		return -EFAULT;
> 
>  	gpio_res->io = devm_ioremap(dev, params->start, size);
> -	if (IS_ERR(gpio_res->io)) {
> +	if (!gpio_res->io) {
>  		devm_release_mem_region(dev, params->start, size);
> -		return PTR_ERR(gpio_res->io);
> +		return -ENOMEM;
>  	}
> 
>  	return 0;
> @@ -1323,9 +1323,9 @@ static int mlxbf_i2c_get_corepll(struct
> platform_device *pdev,
>  		return -EFAULT;
> 
>  	corepll_res->io = devm_ioremap(dev, params->start, size);
> -	if (IS_ERR(corepll_res->io)) {
> +	if (!corepll_res->io) {
>  		devm_release_mem_region(dev, params->start, size);
> -		return PTR_ERR(corepll_res->io);
> +		return -ENOMEM;
>  	}
> 
>  	return 0;
> @@ -1717,9 +1717,9 @@ static int mlxbf_i2c_init_coalesce(struct
> platform_device *pdev,
>  			return -EFAULT;
> 
>  		coalesce_res->io = ioremap(params->start, size);
> -		if (IS_ERR(coalesce_res->io)) {
> +		if (!coalesce_res->io) {
>  			release_mem_region(params->start, size);
> -			return PTR_ERR(coalesce_res->io);
> +			return -ENOMEM;
>  		}
> 
>  		priv->coalesce = coalesce_res;
> --
> 2.25.1

Acked-by: Khalil Blaiech <kblaiech@nvidia.com>

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: mlxbf: Fix the return check of devm_ioremapm and ioremap
  2020-11-11  3:27 [PATCH] i2c: mlxbf: Fix the return check of devm_ioremapm and ioremap Wang Xiaojun
  2020-11-13 22:49 ` Khalil Blaiech
@ 2020-12-02 15:37 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2020-12-02 15:37 UTC (permalink / raw)
  To: Wang Xiaojun; +Cc: kblaiech, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 308 bytes --]

On Wed, Nov 11, 2020 at 11:27:26AM +0800, Wang Xiaojun wrote:
> devm_ioremapm and ioremap may return NULL which cannot be checked
> by IS_ERR.
> 
> Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
> Reported-by: Hulk Robot <hulkci@huawei.com>

Please fix the typo found by Khalil and resend.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-02 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11  3:27 [PATCH] i2c: mlxbf: Fix the return check of devm_ioremapm and ioremap Wang Xiaojun
2020-11-13 22:49 ` Khalil Blaiech
2020-12-02 15:37 ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.