From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754387AbdDQRdP (ORCPT ); Mon, 17 Apr 2017 13:33:15 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:55860 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753810AbdDQRdL (ORCPT ); Mon, 17 Apr 2017 13:33:11 -0400 Date: Mon, 17 Apr 2017 13:33:08 -0400 (EDT) Message-Id: <20170417.133308.930459119262835945.davem@davemloft.net> To: grygorii.strashko@ti.com Cc: netdev@vger.kernel.org, andrew@lunn.ch, f.fainelli@gmail.com, nsekhar@ti.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] net: phy: micrel: fix crash when statistic requested for KSZ9031 phy From: David Miller In-Reply-To: <20170413191127.5406-1-grygorii.strashko@ti.com> References: <20170413191127.5406-1-grygorii.strashko@ti.com> X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 17 Apr 2017 09:51:49 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Grygorii Strashko Date: Thu, 13 Apr 2017 14:11:27 -0500 > 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 Applied.