Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2008555imm; Tue, 10 Jul 2018 11:30:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcUkb8vfiS/AeoItvefygNBQCvdTGPsf7yz/MT86/qNCg6NMVD+RZbXOKQMTfD98iGsuqMF X-Received: by 2002:a63:b91c:: with SMTP id z28-v6mr23828438pge.22.1531247442924; Tue, 10 Jul 2018 11:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531247442; cv=none; d=google.com; s=arc-20160816; b=qqnqNDgPmJUOsKDsLQwXNwGPl4ncK29sL2GaYBf0mpt+Laiq0jAaSi1MJKv6+pIHYd DQI7JRbvuiXSvV0iExR23WZX/Ocm4FSMpqoSG1Gc6ngZ3APp+a+E7qU9Ljv+u1pZ/pdI yLLHu27JCTae682WJDxE7sJhJF+MJgsRtWDzCCz7kDf8sSdIYxd6yJ2WOLzr/ffbBKue JdrvNA0dWWpN5cZF6k9kQueqx/aqZ9yMfGrWGFw2V6dTBhhvMtMUil9hZpA/2s72XpIl KYtw1G+K6oKkSVtBI2aOB7KFSFDYtlIw8nJXY4VL9qekPBgXYhj59jUIHudxNAGaC2kn hDTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8Kk+FK+u9+35l++f0fxX+7eKpIcmJpJWXcaDvlT0pIc=; b=FEI6dB2oggfCWQElOgXybGyr8TPj/XcmUbXSF/S+jXvbzpg/YiwIJX5iP1Pn07j+SQ ybOh8Zr8CYVYLzjnMFyTmCqh/Jsdyovmg1ULTszYVj5r2eDTCgJr2EUOE7DkxeFATzIS OemzupBbH3A9812JBlOB8gNVJEY0oJirSNqaY0bAKzYqkP9d+bBWxKZPQe/p/rs6YhgQ TUpW5odWFq4K8SFBMoPg81eOoGJKm0dAgux8NMdCoN7JSoBrs17YmsoplhMvhHVqU/xs VfCJBXkcChix4XQ7m0tboFZvZhmbDXlbl+fmWUTLWUkUarjOhL8zMLIVCOEVBK/T1sRr SYDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j19-v6si2469173pgg.313.2018.07.10.11.30.26; Tue, 10 Jul 2018 11:30:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387810AbeGJS3i (ORCPT + 99 others); Tue, 10 Jul 2018 14:29:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45366 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732245AbeGJS3h (ORCPT ); Tue, 10 Jul 2018 14:29:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BE5BAEB4; Tue, 10 Jul 2018 18:29:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Grygorii Strashko , Andrew Lunn , Florian Fainelli , "David S. Miller" , Dan Rue Subject: [PATCH 4.9 14/52] net: phy: micrel: fix crash when statistic requested for KSZ9031 phy Date: Tue, 10 Jul 2018 20:24:42 +0200 Message-Id: <20180710182450.939104219@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Grygorii Strashko commit bfe72442578bb112626e476ffe1f276504d85b95 upstream. 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 [] (ethtool_get_phy_stats+0xd8/0x210) (ethtool_get_phy_stats) from [] (dev_ethtool+0x5b8/0x228c) (dev_ethtool) from [] (dev_ioctl+0x3fc/0x964) (dev_ioctl) from [] (sock_ioctl+0x170/0x2c0) (sock_ioctl) from [] (do_vfs_ioctl+0xa8/0x95c) (do_vfs_ioctl) from [] (SyS_ioctl+0x3c/0x64) (SyS_ioctl) from [] (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 Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Cc: Dan Rue Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/micrel.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -801,9 +801,6 @@ static struct phy_driver ksphy_driver[] .read_status = genphy_read_status, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, - .get_sset_count = kszphy_get_sset_count, - .get_strings = kszphy_get_strings, - .get_stats = kszphy_get_stats, .suspend = genphy_suspend, .resume = genphy_resume, }, { @@ -948,9 +945,6 @@ static struct phy_driver ksphy_driver[] .read_status = genphy_read_status, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, - .get_sset_count = kszphy_get_sset_count, - .get_strings = kszphy_get_strings, - .get_stats = kszphy_get_stats, .suspend = genphy_suspend, .resume = genphy_resume, }, { @@ -960,6 +954,7 @@ static struct phy_driver ksphy_driver[] .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause), .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, .driver_data = &ksz9021_type, + .probe = kszphy_probe, .config_init = ksz9021_config_init, .config_aneg = genphy_config_aneg, .read_status = genphy_read_status, @@ -979,6 +974,7 @@ static struct phy_driver ksphy_driver[] .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause), .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, .driver_data = &ksz9021_type, + .probe = kszphy_probe, .config_init = ksz9031_config_init, .config_aneg = genphy_config_aneg, .read_status = ksz9031_read_status, @@ -998,9 +994,6 @@ static struct phy_driver ksphy_driver[] .config_init = kszphy_config_init, .config_aneg = ksz8873mll_config_aneg, .read_status = ksz8873mll_read_status, - .get_sset_count = kszphy_get_sset_count, - .get_strings = kszphy_get_strings, - .get_stats = kszphy_get_stats, .suspend = genphy_suspend, .resume = genphy_resume, }, { @@ -1012,9 +1005,6 @@ static struct phy_driver ksphy_driver[] .config_init = kszphy_config_init, .config_aneg = genphy_config_aneg, .read_status = genphy_read_status, - .get_sset_count = kszphy_get_sset_count, - .get_strings = kszphy_get_strings, - .get_stats = kszphy_get_stats, .suspend = genphy_suspend, .resume = genphy_resume, }, { @@ -1026,9 +1016,6 @@ static struct phy_driver ksphy_driver[] .config_init = kszphy_config_init, .config_aneg = ksz8873mll_config_aneg, .read_status = ksz8873mll_read_status, - .get_sset_count = kszphy_get_sset_count, - .get_strings = kszphy_get_strings, - .get_stats = kszphy_get_stats, .suspend = genphy_suspend, .resume = genphy_resume, } };