aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrygorii Strashko <grygorii.strashko@ti.com>2017-04-13 15:11:27 -0400
committerDavid S. Miller <davem@davemloft.net>2017-04-17 13:29:49 -0400
commitbfe72442578bb112626e476ffe1f276504d85b95 (patch)
treec85040bcbc59aae62514c7204c6bb5108c18e699
parent426c87caa2b4578b43cd3f689f02c65b743b2559 (diff)
net: phy: micrel: fix crash when statistic requested for KSZ9031 phy
Now the command: ethtool --phy-statistics eth0 will cause system crash with meassage "Unable to handle kernel NULL pointer dereference at virtual address 00000010" from: (kszphy_get_stats) from [<c069f1d8>] (ethtool_get_phy_stats+0xd8/0x210) (ethtool_get_phy_stats) from [<c06a0738>] (dev_ethtool+0x5b8/0x228c) (dev_ethtool) from [<c06b5484>] (dev_ioctl+0x3fc/0x964) (dev_ioctl) from [<c0679f7c>] (sock_ioctl+0x170/0x2c0) (sock_ioctl) from [<c02419d4>] (do_vfs_ioctl+0xa8/0x95c) (do_vfs_ioctl) from [<c02422c4>] (SyS_ioctl+0x3c/0x64) (SyS_ioctl) from [<c0107d60>] (ret_fast_syscall+0x0/0x44) The reason: phy_driver structure for KSZ9031 phy has no .probe() callback defined. As result, struct phy_device *phydev->priv pointer will not be initializes (null). This issue will affect also following phys: KSZ8795, KSZ886X, KSZ8873MLL, KSZ9031, KSZ9021, KSZ8061, KS8737 Fix it by: - adding .probe() = kszphy_probe() callback to KSZ9031, KSZ9021 phys. The kszphy_probe() can be re-used as it doesn't do any phy specific settings. - removing statistic callbacks from other phys (KSZ8795, KSZ886X, KSZ8873MLL, KSZ8061, KS8737) as they doesn't have corresponding statistic counters. Fixes: 2b2427d06426 ("phy: micrel: Add ethtool statistics counters") Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/phy/micrel.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 6742070ca676..1326d99771c1 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -798,9 +798,6 @@ static struct phy_driver ksphy_driver[] = {
798 .read_status = genphy_read_status, 798 .read_status = genphy_read_status,
799 .ack_interrupt = kszphy_ack_interrupt, 799 .ack_interrupt = kszphy_ack_interrupt,
800 .config_intr = kszphy_config_intr, 800 .config_intr = kszphy_config_intr,
801 .get_sset_count = kszphy_get_sset_count,
802 .get_strings = kszphy_get_strings,
803 .get_stats = kszphy_get_stats,
804 .suspend = genphy_suspend, 801 .suspend = genphy_suspend,
805 .resume = genphy_resume, 802 .resume = genphy_resume,
806}, { 803}, {
@@ -940,9 +937,6 @@ static struct phy_driver ksphy_driver[] = {
940 .read_status = genphy_read_status, 937 .read_status = genphy_read_status,
941 .ack_interrupt = kszphy_ack_interrupt, 938 .ack_interrupt = kszphy_ack_interrupt,
942 .config_intr = kszphy_config_intr, 939 .config_intr = kszphy_config_intr,
943 .get_sset_count = kszphy_get_sset_count,
944 .get_strings = kszphy_get_strings,
945 .get_stats = kszphy_get_stats,
946 .suspend = genphy_suspend, 940 .suspend = genphy_suspend,
947 .resume = genphy_resume, 941 .resume = genphy_resume,
948}, { 942}, {
@@ -952,6 +946,7 @@ static struct phy_driver ksphy_driver[] = {
952 .features = PHY_GBIT_FEATURES, 946 .features = PHY_GBIT_FEATURES,
953 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 947 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
954 .driver_data = &ksz9021_type, 948 .driver_data = &ksz9021_type,
949 .probe = kszphy_probe,
955 .config_init = ksz9021_config_init, 950 .config_init = ksz9021_config_init,
956 .config_aneg = genphy_config_aneg, 951 .config_aneg = genphy_config_aneg,
957 .read_status = genphy_read_status, 952 .read_status = genphy_read_status,
@@ -971,6 +966,7 @@ static struct phy_driver ksphy_driver[] = {
971 .features = PHY_GBIT_FEATURES, 966 .features = PHY_GBIT_FEATURES,
972 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 967 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
973 .driver_data = &ksz9021_type, 968 .driver_data = &ksz9021_type,
969 .probe = kszphy_probe,
974 .config_init = ksz9031_config_init, 970 .config_init = ksz9031_config_init,
975 .config_aneg = genphy_config_aneg, 971 .config_aneg = genphy_config_aneg,
976 .read_status = ksz9031_read_status, 972 .read_status = ksz9031_read_status,
@@ -989,9 +985,6 @@ static struct phy_driver ksphy_driver[] = {
989 .config_init = kszphy_config_init, 985 .config_init = kszphy_config_init,
990 .config_aneg = ksz8873mll_config_aneg, 986 .config_aneg = ksz8873mll_config_aneg,
991 .read_status = ksz8873mll_read_status, 987 .read_status = ksz8873mll_read_status,
992 .get_sset_count = kszphy_get_sset_count,
993 .get_strings = kszphy_get_strings,
994 .get_stats = kszphy_get_stats,
995 .suspend = genphy_suspend, 988 .suspend = genphy_suspend,
996 .resume = genphy_resume, 989 .resume = genphy_resume,
997}, { 990}, {
@@ -1003,9 +996,6 @@ static struct phy_driver ksphy_driver[] = {
1003 .config_init = kszphy_config_init, 996 .config_init = kszphy_config_init,
1004 .config_aneg = genphy_config_aneg, 997 .config_aneg = genphy_config_aneg,
1005 .read_status = genphy_read_status, 998 .read_status = genphy_read_status,
1006 .get_sset_count = kszphy_get_sset_count,
1007 .get_strings = kszphy_get_strings,
1008 .get_stats = kszphy_get_stats,
1009 .suspend = genphy_suspend, 999 .suspend = genphy_suspend,
1010 .resume = genphy_resume, 1000 .resume = genphy_resume,
1011}, { 1001}, {
@@ -1017,9 +1007,6 @@ static struct phy_driver ksphy_driver[] = {
1017 .config_init = kszphy_config_init, 1007 .config_init = kszphy_config_init,
1018 .config_aneg = ksz8873mll_config_aneg, 1008 .config_aneg = ksz8873mll_config_aneg,
1019 .read_status = ksz8873mll_read_status, 1009 .read_status = ksz8873mll_read_status,
1020 .get_sset_count = kszphy_get_sset_count,
1021 .get_strings = kszphy_get_strings,
1022 .get_stats = kszphy_get_stats,
1023 .suspend = genphy_suspend, 1010 .suspend = genphy_suspend,
1024 .resume = genphy_resume, 1011 .resume = genphy_resume,
1025} }; 1012} };