Skip to content

Commit

Permalink
net: ethernet: ti: cpsw: fix NULL pointer dereference in switch mode
Browse files Browse the repository at this point in the history
In switch mode on struct cpsw_slave->ndev field will be initialized with
proper value only for the one cpsw slave port, as result
cpsw_get_usage_count() will generate "Unable to handle kernel NULL pointer
dereference" exception when first ethernet interface is opening
cpsw_ndo_open(). This issue causes boot regression on AM335x EVM and
reproducible on am57xx-evm (switch mode).
Fix it by adding additional check for !cpsw->slaves[i].ndev in
cpsw_get_usage_count().

Cc: Ivan Khoronzhuk <[email protected]>
Fixes: 03fd01a ("net: ethernet: ti: cpsw: don't duplicate ndev_running")
Signed-off-by: Grygorii Strashko <[email protected]>
Reviewed-by: Ivan Khoronzhuk <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
grygoriyS authored and davem330 committed Feb 1, 2017
1 parent b2504a5 commit f696186
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/ti/cpsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ static int cpsw_get_usage_count(struct cpsw_common *cpsw)
u32 usage_count = 0;

for (i = 0; i < cpsw->data.slaves; i++)
if (netif_running(cpsw->slaves[i].ndev))
if (cpsw->slaves[i].ndev && netif_running(cpsw->slaves[i].ndev))
usage_count++;

return usage_count;
Expand Down

0 comments on commit f696186

Please sign in to comment.