]> git.baikalelectronics.ru Git - kernel.git/commit
net: ethernet: ti: cpsw: fix NULL pointer dereference in switch mode
authorGrygorii Strashko <grygorii.strashko@ti.com>
Tue, 31 Jan 2017 20:04:04 +0000 (14:04 -0600)
committerDavid S. Miller <davem@davemloft.net>
Wed, 1 Feb 2017 17:05:51 +0000 (12:05 -0500)
commit1b965c95887878d73716a0e883e4465e92c2369c
tree6e9f8d9cc02b333153a203b29ae62168063317f9
parent6f6464ff2ac9005b793d395a767d14f1c117c76f
net: ethernet: ti: cpsw: fix NULL pointer dereference in switch mode

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 <ivan.khoronzhuk@linaro.org>
Fixes: ac3b4689642a ("net: ethernet: ti: cpsw: don't duplicate ndev_running")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpsw.c