Received: by 10.192.165.156 with SMTP id m28csp1090175imm; Wed, 11 Apr 2018 12:13:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/daGH5OVW0tWH8++/kBzuu0pM1Fy296TzESuTxSBfa39R0RLiQWUegsYxOvW1g3VY2dB7J X-Received: by 2002:a17:902:2c83:: with SMTP id n3-v6mr6471238plb.317.1523473985337; Wed, 11 Apr 2018 12:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523473985; cv=none; d=google.com; s=arc-20160816; b=NyfZgLn8Fe4s+Lpx42UPiErO+rMuAXU4TJ58bGy6y1CQhSM01Sg6wmCPnm0CsLkPJ/ 8Ql6sOPfVxNmZuokCi9hzRaJIh/1EuJrcPeCqNMGuqFmjPdf3EljLVcewD0FMHW9ZDYp I7W40mmo4NwZ1NwVG31qD+GIGlicf1JZxcLgSACrf8LIifN8oxDPLOtcPQgIdRYra7XI FmGfATZhZUXM+gR0uAJJFgieecDC/ZqzmO6PdLaDvaxOAlJr+QR+3i5T+A1u35tCqvEi GcrJ3p8Rgtlbhavg2UWCARN6L7EOYEH+ejEVBHITxKYnCla58k23oj8bKPgUXKILNdFm y+6A== 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=/2mqvTe7bc6kzq5i3l2E9yeyc1QVEmnWyGYPTTspkXg=; b=HHBabYIu+UV/YhcjHTbEFhogGKWfjacbUXiddkLaHqPq1pvuBkbkYjVOM4hhoOzofL uTpui3qJSVJVrGle1VdNzU68c63rqsEBjSIYrtYCN91AsQYAcxcCk6etN/xlysVTdqRz iCj3XUMv0w+AyfSjfkDuBQZXpnG0r47wbcO3bkh6PeHbpjTNMNtZIe1ALfNdYfsgNmHj 4bVPdz++1nOUl08rj0hZux4grI6lEdHxqhsT/195KBsVtiK3ehJDjoBdScHZ+pMmA94E mvlMM+oIKXGn2Kqvy+Rup9gWkf+79L2CwV5YFp4ER+xj3sONjlt3uq+uNWWsxxwj4YFH vN9A== 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 g6-v6si1754643pln.619.2018.04.11.12.12.28; Wed, 11 Apr 2018 12:13:05 -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 S935138AbeDKTGB (ORCPT + 99 others); Wed, 11 Apr 2018 15:06:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40656 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934041AbeDKTF5 (ORCPT ); Wed, 11 Apr 2018 15:05:57 -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 C67B5D3C; Wed, 11 Apr 2018 19:05:56 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Miller , Heiner Kallweit Subject: [PATCH 4.9 284/310] r8169: fix setting driver_data after register_netdev Date: Wed, 11 Apr 2018 20:37:03 +0200 Message-Id: <20180411183634.818819687@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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: Heiner Kallweit [ Upstream commit 19c9ea363a244f85f90a424f9936e6d56449e33c ] pci_set_drvdata() is called only after registering the net_device, therefore we could run into a NPE if one of the functions using driver_data is called before it's set. Fix this by calling pci_set_drvdata() before registering the net_device. This fix is a candidate for stable. As far as I can see the bug has been there in kernel version 3.2 already, therefore I can't provide a reference which commit is fixed by it. The fix may need small adjustments per kernel version because due to other changes the label which is jumped to if register_netdev() fails has changed over time. Reported-by: David Miller Signed-off-by: Heiner Kallweit Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/realtek/r8169.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -8446,12 +8446,12 @@ static int rtl_init_one(struct pci_dev * goto err_out_msi_5; } + pci_set_drvdata(pdev, dev); + rc = register_netdev(dev); if (rc < 0) goto err_out_cnt_6; - pci_set_drvdata(pdev, dev); - netif_info(tp, probe, dev, "%s at 0x%p, %pM, XID %08x IRQ %d\n", rtl_chip_infos[chipset].name, ioaddr, dev->dev_addr, (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), pdev->irq);