Received: by 10.192.165.156 with SMTP id m28csp34967imm; Tue, 10 Apr 2018 15:51:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx49rwfOr5/3icu7E11Ague9KAi1tMTZy+mUS1nVDC58v8NwjJdu9nyfEDt/t5BIyAtGThEZo X-Received: by 2002:a17:902:264:: with SMTP id 91-v6mr2362730plc.178.1523400670877; Tue, 10 Apr 2018 15:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523400670; cv=none; d=google.com; s=arc-20160816; b=pY5AlJGnJsOUIarUxcb0FJllz+a0pgV+PSSjqW+79zE/YnDbc92bL2K+5iV1otTUGo 6TbQNhE4Ye3j3vZYTNgxwIeSKVNk/EhzdO0+JotBuBh6S4X1uJe5FVeZO8Zv8OJgjtwI Wxn+TF+9elj/SBHpSzVW2KQG1+pap9aGbM3NQHFP85x+IvoqQ9MHNIttqWCnRF9DJ612 gszUKoiYq8f1JvxCk69568KeEApkzRMzJuUEW6iXJJHluo+NuNZ8RhSqapMKp8/wjrMK Eah0NdP28cM+XoDvC1f95IPpQFqjjf921Or0UdD68Vh4h8GJDyaqjt/c2ZUQp7QcK8E0 M6iQ== 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=pN6C5zDUiJ0m/k/mZaKq0xAU+VQBxz9DiSAZVelq4pU=; b=rEDo3dAGl4+qtl4F+Ly5SNFwPkatN0OiiXM5XymGkVr+29lEb1VFlHOLrVikFmScMK E5Fa+VDIxHvgiRlf6a2mA0lv1HDRHT0A54uVQPL3zaQGxamZ8D8w+LUTcfxNjQaDXarv 6KiRJZ/dAf8bRoz4Lat3XncVjV9CVIqvZgVue6buY8TMRO/ZZ18fbSGUrX8q/QUzQNRO JUhmxoIZ2HoT6b19YCP+6V9xh03PE1rzUDSBEIfeD1L4l17Tj7Z4tZffJqooHG+voGlh E+1x5yip0Ubaege2zi1uuTAMCYG8DG+pCwfXhFYCy+04/CmYjxsj9qPBld68nJUFZ3qr Z5Ww== 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 11-v6si3535893plb.658.2018.04.10.15.50.34; Tue, 10 Apr 2018 15:51:10 -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 S932484AbeDJWiy (ORCPT + 99 others); Tue, 10 Apr 2018 18:38:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44988 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755267AbeDJWiv (ORCPT ); Tue, 10 Apr 2018 18:38:51 -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 D1C4F408; Tue, 10 Apr 2018 22:38:50 +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.14 107/138] r8169: fix setting driver_data after register_netdev Date: Wed, 11 Apr 2018 00:24:57 +0200 Message-Id: <20180410212914.642411927@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@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.14-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 @@ -8466,12 +8466,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);