Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3729046imm; Mon, 8 Oct 2018 08:36:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV63xz8658g626VlklS9lsSCbtwdmdUouqCmP9Y0usfYZMAGX4XpnHanvGELrekNUhRkoTrh1 X-Received: by 2002:a17:902:33c2:: with SMTP id b60-v6mr24527927plc.105.1539012998332; Mon, 08 Oct 2018 08:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539012998; cv=none; d=google.com; s=arc-20160816; b=RkmVDaNHvfhXRN2o17xbucJjGWO3YjnOD9HfLYp7w3zvoYXQgCLIwfZsQ5Y/O4CAnw pOL2b4543cbZUN8CPA2iX2fD0D0TxrOFVcNa0bG+O23yOtkOO4iwuHEU3aTKuaC790Jt 21qeQDLv6x8FANuX3eHVu4+UgL1ooYLJukbqhBGnwrafvXPeR2xSOdUyNLnuKMOv9r4w a4G4GdvUyq37hNEksRMBULTLhHSEn+02U2HRi9kAZc8RKN2kTFWfXAROuV1rnSlYYFuK giEs4pUnT3xn5OpTuKruWyEmfiF1GKdWdAZkiagjIhRHNs1UOJ3KCEQjKgfDUEg+eJSS m4zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=sxSAvbPlEpSbe1gg3PW6o7Z42W5HkEMndNNEtimCTkA=; b=OfF6MC2nfpTbqEzi66/hZluNnqxG+9ZOH/Kj3L6BGN6HEGC9vdrpjHpEY7fqIabzzO fEaSdUhDVxJRnK34mAMynl+pPs3meNqD1VWEdq+a1DLNIeCKmqKMJu4G9MIP+Zco2QT3 /U4c3EriMyk5aEoO5gjz68ZM1CKqZEth/QuMqTW3zgkpP9x7+k+xXnJmRXJSrgsn5eW8 f10UzyKAFOMyuJvdxZ+iJnRRk+CzhxRGYc4gkeMVvd0RRg1VvMbFHS6jqhGOGjXv806E 1WaJcrF1isHSs+FtCWgMiHqNwnkOg3SMuD0BbUgrsBS1/LM7XDPyn7KCVlBqtHFz4A1o jJPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GweR150Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i64-v6si19902397pfg.119.2018.10.08.08.36.23; Mon, 08 Oct 2018 08:36:38 -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; dkim=pass header.i=@kernel.org header.s=default header.b=GweR150Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727627AbeJHWiO (ORCPT + 99 others); Mon, 8 Oct 2018 18:38:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:56574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727579AbeJHWiN (ORCPT ); Mon, 8 Oct 2018 18:38:13 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0D6B4214FF; Mon, 8 Oct 2018 15:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012358; bh=rltvIn4o2zcs/1arH//lVR2leOxioqCz5oojeZJD01A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GweR150QZAEp5FNzci3/jhFPFtki/BOT4Mv8UKQepDh9jZNfTafikwdVbChoff3Cw X4eEbwBQYPats20jy7LxLbp51Z5Ib88VoSNXeKFTijUio8CKK5WR3TpEITx+Ql+Ndn jR61rIyaoXxZ8e3hLM04W/VHWJ9nHZlmGc1GiSOE= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Russell King , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.18 33/58] sfp: fix oops with ethtool -m Date: Mon, 8 Oct 2018 11:24:58 -0400 Message-Id: <20181008152523.70705-33-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell King [ Upstream commit 126d6848ef13958e1cb959e96c21d19bc498ade9 ] If a network interface is created prior to the SFP socket being available, ethtool can request module information. This unfortunately leads to an oops: Unable to handle kernel NULL pointer dereference at virtual address 00000008 pgd = (ptrval) [00000008] *pgd=7c400831, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#1] SMP ARM Modules linked in: CPU: 0 PID: 1480 Comm: ethtool Not tainted 4.19.0-rc3 #138 Hardware name: Broadcom Northstar Plus SoC PC is at sfp_get_module_info+0x8/0x10 LR is at dev_ethtool+0x218c/0x2afc Fix this by not filling in the network device's SFP bus pointer until SFP is fully bound, thereby avoiding the core calling into the SFP bus code. Fixes: ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices and sfp cages") Reported-by: Florian Fainelli Tested-by: Florian Fainelli Signed-off-by: Russell King Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/sfp-bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index 740655261e5b..83060fb349f4 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -349,6 +349,7 @@ static int sfp_register_bus(struct sfp_bus *bus) } if (bus->started) bus->socket_ops->start(bus->sfp); + bus->netdev->sfp_bus = bus; bus->registered = true; return 0; } @@ -357,6 +358,7 @@ static void sfp_unregister_bus(struct sfp_bus *bus) { const struct sfp_upstream_ops *ops = bus->upstream_ops; + bus->netdev->sfp_bus = NULL; if (bus->registered) { if (bus->started) bus->socket_ops->stop(bus->sfp); @@ -438,7 +440,6 @@ static void sfp_upstream_clear(struct sfp_bus *bus) { bus->upstream_ops = NULL; bus->upstream = NULL; - bus->netdev->sfp_bus = NULL; bus->netdev = NULL; } @@ -467,7 +468,6 @@ struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode, bus->upstream_ops = ops; bus->upstream = upstream; bus->netdev = ndev; - ndev->sfp_bus = bus; if (bus->sfp) { ret = sfp_register_bus(bus); -- 2.17.1