Received: by 10.192.165.156 with SMTP id m28csp26435imm; Tue, 10 Apr 2018 15:39:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+yL7J7hG979pqHUakuS3kcbbUnghw7SpyRCYzusiOzD48QYeQKBDyEnxPu8aSFIF78hBn5 X-Received: by 2002:a17:902:a70f:: with SMTP id w15-v6mr2338119plq.344.1523399983817; Tue, 10 Apr 2018 15:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523399983; cv=none; d=google.com; s=arc-20160816; b=KgZg60zcSg/zpTa+jGHmhc5aqF8bbs33BB7IQJ/kHOBHH1kaK6xlg88/5a6ts3q6AA 5ed2JVU6wO40f5wtERODtqn0jI7y7+WqLXHEWkO4N/JY6dEsAsGtgQ3qN5ED6wZPnpta 6a7LSa8YtZxoygo8juKYA+bvb0Ai8YCagE3nhlwptxDamL12Ss2kUhhJzlvyCXb9SRM4 FYP63bUcW6qXCat2jxpbs6YvzdSBhyn4EfeCmMU6u30qNyqdbnFazNS9mxXGpVdsYsCJ 2dsDpLuPEzxsnArfNFahIBX7UdwMUGhdfX3ZwT6mXJUywkaFSSGyMZwfI+1yHv9+uoue W8xw== 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=dvhN93XXhp4ZFxpFFc6JoYyxx0GU5TFXMVbIlU34v3A=; b=bSUn29bIXjWb/YxGDTGob5dt9QxLDw/o3bhJ2iRe2fr1EP2FyZahKMxgoQ+ehQT+qu pAUUexQBlZK48ZJkepo9c6D6pqAjuykkf+CAVXd7AHJx5ddMkdhAiJctFhgUUjHGvMm6 HT0vUkoh5wWOtcF6SwAtoUCxEcK5QhqWgxxMEreqiIhIa/5oYyXDx9NYJFFw33305Wkk sqAYGYYsfWKAdMMUpOUfeqhRcxYH76sB3SmyZINLdl3V+qvcel0lC5UfOMs3ucA0Lchy Gi6n+WAyaUesX9cp5w5KE9N1NNrpZBz/3ymtXLswPopCrfYYy4BRhqg1gT0sP8W87IoM r4qg== 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 o81si2894787pfa.64.2018.04.10.15.39.07; Tue, 10 Apr 2018 15:39:43 -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 S1755172AbeDJWdI (ORCPT + 99 others); Tue, 10 Apr 2018 18:33:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41160 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755146AbeDJWdG (ORCPT ); Tue, 10 Apr 2018 18:33:06 -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 5D4B2BCF; Tue, 10 Apr 2018 22:33:05 +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.15 133/168] r8169: fix setting driver_data after register_netdev Date: Wed, 11 Apr 2018 00:24:35 +0200 Message-Id: <20180410212806.641864901@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@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.15-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 @@ -8699,12 +8699,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);