Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1681292 > unrolled thread

[PATCH] mfd: Fix potential NULL pointer dereference

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2017-07-05 08:00 +0200
Last post2017-07-17 14:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mfd: Fix potential NULL pointer dereference Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-07-05 08:00 +0200
    Re: [PATCH] mfd: Fix potential NULL pointer dereference Lee Jones <lee.jones@linaro.org> - 2017-07-17 14:30 +0200

#1681292 — [PATCH] mfd: Fix potential NULL pointer dereference

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2017-07-05 08:00 +0200
Subject[PATCH] mfd: Fix potential NULL pointer dereference
Message-ID<tZLvX-2b1-1@gated-at.bofh.it>
if 'max8998_i2c_parse_dt_pdata() fails (when out of memory), a NULL
pointer dereference will occur in the error handling code.

Return directly instead.

Fixes: ee999fb3f17f("mfd: max8998: Add support for Device Tree")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mfd/max8998.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index 4c33b8063bc3..b1d3f70782d9 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -192,10 +192,8 @@ static int max8998_i2c_probe(struct i2c_client *i2c,
 
 	if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) {
 		pdata = max8998_i2c_parse_dt_pdata(&i2c->dev);
-		if (IS_ERR(pdata)) {
-			ret = PTR_ERR(pdata);
-			goto err;
-		}
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
 	}
 
 	i2c_set_clientdata(i2c, max8998);
-- 
2.11.0

[toc] | [next] | [standalone]


#1688980

FromLee Jones <lee.jones@linaro.org>
Date2017-07-17 14:30 +0200
Message-ID<u4djX-4Wt-1@gated-at.bofh.it>
In reply to#1681292
On Wed, 05 Jul 2017, Christophe JAILLET wrote:

> if 'max8998_i2c_parse_dt_pdata() fails (when out of memory), a NULL
> pointer dereference will occur in the error handling code.
> 
> Return directly instead.
> 
> Fixes: ee999fb3f17f("mfd: max8998: Add support for Device Tree")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/mfd/max8998.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
> index 4c33b8063bc3..b1d3f70782d9 100644
> --- a/drivers/mfd/max8998.c
> +++ b/drivers/mfd/max8998.c
> @@ -192,10 +192,8 @@ static int max8998_i2c_probe(struct i2c_client *i2c,
>  
>  	if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) {
>  		pdata = max8998_i2c_parse_dt_pdata(&i2c->dev);
> -		if (IS_ERR(pdata)) {
> -			ret = PTR_ERR(pdata);
> -			goto err;
> -		}
> +		if (IS_ERR(pdata))
> +			return PTR_ERR(pdata);
>  	}
>  
>  	i2c_set_clientdata(i2c, max8998);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web