* [PATCH net] net: cpsw: fix NULL pointer exception in the probe error path
@ 2019-08-21 14:41 Antoine Tenart
2019-08-21 15:02 ` Grygorii Strashko
2019-08-21 21:00 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Antoine Tenart @ 2019-08-21 14:41 UTC (permalink / raw)
To: davem, grygorii.strashko
Cc: Antoine Tenart, netdev, linux-omap, linux-kernel,
maxime.chevallier
In certain cases when the probe function fails the error path calls
cpsw_remove_dt() before calling platform_set_drvdata(). This is an
issue as cpsw_remove_dt() uses platform_get_drvdata() to retrieve the
cpsw_common data and leds to a NULL pointer exception. This patches
fixes it by calling platform_set_drvdata() earlier in the probe.
Fixes: 83a8471ba255 ("net: ethernet: ti: cpsw: refactor probe to group common hw initialization")
Reported-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
---
drivers/net/ethernet/ti/cpsw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 32a89744972d..a46b8b2e44e1 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2775,6 +2775,7 @@ static int cpsw_probe(struct platform_device *pdev)
if (!cpsw)
return -ENOMEM;
+ platform_set_drvdata(pdev, cpsw);
cpsw->dev = dev;
mode = devm_gpiod_get_array_optional(dev, "mode", GPIOD_OUT_LOW);
@@ -2879,7 +2880,6 @@ static int cpsw_probe(struct platform_device *pdev)
goto clean_cpts;
}
- platform_set_drvdata(pdev, cpsw);
priv = netdev_priv(ndev);
priv->cpsw = cpsw;
priv->ndev = ndev;
--
2.21.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: cpsw: fix NULL pointer exception in the probe error path
2019-08-21 14:41 [PATCH net] net: cpsw: fix NULL pointer exception in the probe error path Antoine Tenart
@ 2019-08-21 15:02 ` Grygorii Strashko
2019-08-21 21:00 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Grygorii Strashko @ 2019-08-21 15:02 UTC (permalink / raw)
To: Antoine Tenart, davem; +Cc: netdev, linux-omap, linux-kernel, maxime.chevallier
On 21/08/2019 17:41, Antoine Tenart wrote:
> In certain cases when the probe function fails the error path calls
> cpsw_remove_dt() before calling platform_set_drvdata(). This is an
> issue as cpsw_remove_dt() uses platform_get_drvdata() to retrieve the
> cpsw_common data and leds to a NULL pointer exception. This patches
> fixes it by calling platform_set_drvdata() earlier in the probe.
>
> Fixes: 83a8471ba255 ("net: ethernet: ti: cpsw: refactor probe to group common hw initialization")
> Reported-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
> ---
> drivers/net/ethernet/ti/cpsw.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Thank you.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
--
Best regards,
grygorii
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: cpsw: fix NULL pointer exception in the probe error path
2019-08-21 14:41 [PATCH net] net: cpsw: fix NULL pointer exception in the probe error path Antoine Tenart
2019-08-21 15:02 ` Grygorii Strashko
@ 2019-08-21 21:00 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-08-21 21:00 UTC (permalink / raw)
To: antoine.tenart
Cc: grygorii.strashko, netdev, linux-omap, linux-kernel,
maxime.chevallier
From: Antoine Tenart <antoine.tenart@bootlin.com>
Date: Wed, 21 Aug 2019 16:41:23 +0200
> In certain cases when the probe function fails the error path calls
> cpsw_remove_dt() before calling platform_set_drvdata(). This is an
> issue as cpsw_remove_dt() uses platform_get_drvdata() to retrieve the
> cpsw_common data and leds to a NULL pointer exception. This patches
> fixes it by calling platform_set_drvdata() earlier in the probe.
>
> Fixes: 83a8471ba255 ("net: ethernet: ti: cpsw: refactor probe to group common hw initialization")
> Reported-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-21 21:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-21 14:41 [PATCH net] net: cpsw: fix NULL pointer exception in the probe error path Antoine Tenart
2019-08-21 15:02 ` Grygorii Strashko
2019-08-21 21:00 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).