]> git.baikalelectronics.ru Git - kernel.git/commit
net: cpsw: fix NULL pointer exception in the probe error path
authorAntoine Tenart <antoine.tenart@bootlin.com>
Wed, 21 Aug 2019 14:41:23 +0000 (16:41 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Aug 2019 20:58:15 +0000 (13:58 -0700)
commite571b927d335aa5b54606c351d5255e6a21a77c4
treed51f1f46b8cfb1483a8b813393f194fe251118e6
parentc700c22e86e362991837b70079de581446137e5d
net: cpsw: fix NULL pointer exception in the probe error path

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: 8a7c9d2b28fa ("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>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpsw.c