public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: mux: pinctrl: potential NULL dereference on error
@ 2017-08-17 11:53 Dan Carpenter
  2017-08-17 12:34 ` Peter Rosin
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-08-17 11:53 UTC (permalink / raw)
  To: Peter Rosin; +Cc: Wolfram Sang, linux-i2c, kernel-janitors

If i2c_mux_alloc() fails then we'd have a NULL dereference here.

Fixes: c4aee3e1b0de ("i2c: mux: pinctrl: remove platform_data")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index 20b90a7a1e61..cc6818aabab5 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -173,7 +173,7 @@ static int i2c_mux_pinctrl_probe(struct platform_device *pdev)
 err_del_adapter:
 	i2c_mux_del_adapters(muxc);
 err_put_parent:
-	i2c_put_adapter(muxc->parent);
+	i2c_put_adapter(parent);
 
 	return ret;
 }

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

* Re: [PATCH] i2c: mux: pinctrl: potential NULL dereference on error
  2017-08-17 11:53 [PATCH] i2c: mux: pinctrl: potential NULL dereference on error Dan Carpenter
@ 2017-08-17 12:34 ` Peter Rosin
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Rosin @ 2017-08-17 12:34 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Wolfram Sang, linux-i2c, kernel-janitors


On 2017-08-17 13:53, Dan Carpenter wrote:
> If i2c_mux_alloc() fails then we'd have a NULL derefecrence here.
> 
> Fixes: c4aee3e1b0de ("i2c: mux: pinctrl: remove platform_data")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Indeed, thanks for the patch. Applied.

(IIUC, small memory allocations are not supposed to fail so this is
 not really a "real" problem?)

FTR, I have work in progress that further cleans up i2c muxes.
Most .remove functions disappear from drivers/i2c/muxes/ and
most i2c mux users outside of i2c/muxes are also simplified for
a nice net loss in lines-of-code, and this bug would simply not
have happened with that. Oh well, that's not for the this cycle
anyway...

Cheers,
peda

> diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> index 20b90a7a1e61..cc6818aabab5 100644
> --- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
> +++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> @@ -173,7 +173,7 @@ static int i2c_mux_pinctrl_probe(struct platform_device *pdev)
>  err_del_adapter:
>  	i2c_mux_del_adapters(muxc);
>  err_put_parent:
> -	i2c_put_adapter(muxc->parent);
> +	i2c_put_adapter(parent);
>  
>  	return ret;
>  }
> 


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

end of thread, other threads:[~2017-08-17 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17 11:53 [PATCH] i2c: mux: pinctrl: potential NULL dereference on error Dan Carpenter
2017-08-17 12:34 ` Peter Rosin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox