Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3321805pxf; Mon, 15 Mar 2021 07:06:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+L6fKk+Glv4yXwAigUuqA+M8xXvLJ7yGsVgGk6JvlI4KNrqetqa8qCLlW8i/0fGuCeLWD X-Received: by 2002:aa7:cb4d:: with SMTP id w13mr30279399edt.249.1615817214215; Mon, 15 Mar 2021 07:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817214; cv=none; d=google.com; s=arc-20160816; b=ITj4R/u0+x1FTsT2QDqtQyDJ9m1jHcr9uQ5Wg07WPwJZ7aepeO4PW9r8s8NtziAV8H wabp47HDHqA+jxaRHwritTX9aOGzPACaMRedcLGwD9BY0Fx+fSRsWvdwtxwBMyqqcs5C idW2kw5D2WZa4xqrXAm+WAfs36It7PeK3fMd/y4Oos7BKBdkcnvW7dyHZlKU5vNe6Eny 0MwKSDcEkPYNV9ZbrOlx8uCbvG/EtiGl/GB1yXUk+rbflFB3NxQo3utB7G9R4XETNgqy f9VrFDCxTmHlzPI7xWHdSBh4fZ967YZmtEVVowPkYCRtCbb+ydhVkFOzRvPFRiuOL8YJ c5mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mkNWQYeoI5Xa3ZO2zRSvf3GnOYOnL5Rvtgq7T6MMby0=; b=Qkk0i1tkbdml/GOn24XHmbCuMo8xVOnAWeeYoW84Ye4a+ubnUOlwxaYphj3TIIkL+6 Zat3J7jFD2OlKAjicsBJauJ+Rh0gp0pltj7F99AWt2hUCiC36FREpWAmH//UyQ82xPln eT+KENPdegJjVJM1awTeM7AtyxhkidDq/oXmTmZRe1ipkm1E5QayOUDQ0h+iynAyuC3n 7NnPs9mD9a/PGmuKitdW3KHuHmpz516f3G8vidhELzjbbBH7aQH8O+cFAQRy9SJNCZB4 xmNnxOOAz3heUdIhLXfBJ2rSzv2/c6zxydEdmfm9PCudNra4G2Hb3GRMSfK3i2p1+Goc K9ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jo6D/wMk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jo14si11448788ejb.460.2021.03.15.07.06.31; Mon, 15 Mar 2021 07:06:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jo6D/wMk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233748AbhCOOCY (ORCPT + 99 others); Mon, 15 Mar 2021 10:02:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:33716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbhCON4u (ORCPT ); Mon, 15 Mar 2021 09:56:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4467364EEC; Mon, 15 Mar 2021 13:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816610; bh=JSO7HjCPXzECWUoqg072bc6aHfuQwXZ6MlP0UVke4xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jo6D/wMkopTw3DbBRRKbaUdT1im7Z/lAm4RgUGznMHM6XaWohuU/f6EYnTN+kLrar nh2jzufYsEA9iRT5dHEWOt2RVS7kxmfDZ0OraaFdHdhjC31zsqHb973EqA9slZwFNw Nl5VE8lpZ0/UVhTRBzo9FL/M5LvZS6t9tJUxMHUU= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zbynek Michl , Jakub Kicinski , "David S. Miller" Subject: [PATCH 5.4 003/168] ethernet: alx: fix order of calls on resume Date: Mon, 15 Mar 2021 14:53:55 +0100 Message-Id: <20210315135550.448416136@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Jakub Kicinski commit a4dcfbc4ee2218abd567d81d795082d8d4afcdf6 upstream. netif_device_attach() will unpause the queues so we can't call it before __alx_open(). This went undetected until commit b0999223f224 ("alx: add ability to allocate and free alx_napi structures") but now if stack tries to xmit immediately on resume before __alx_open() we'll crash on the NAPI being null: BUG: kernel NULL pointer dereference, address: 0000000000000198 CPU: 0 PID: 12 Comm: ksoftirqd/0 Tainted: G OE 5.10.0-3-amd64 #1 Debian 5.10.13-1 Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./H77-D3H, BIOS F15 11/14/2013 RIP: 0010:alx_start_xmit+0x34/0x650 [alx] Code: 41 56 41 55 41 54 55 53 48 83 ec 20 0f b7 57 7c 8b 8e b0 0b 00 00 39 ca 72 06 89 d0 31 d2 f7 f1 89 d2 48 8b 84 df RSP: 0018:ffffb09240083d28 EFLAGS: 00010297 RAX: 0000000000000000 RBX: ffffa04d80ae7800 RCX: 0000000000000004 RDX: 0000000000000000 RSI: ffffa04d80afa000 RDI: ffffa04e92e92a00 RBP: 0000000000000042 R08: 0000000000000100 R09: ffffa04ea3146700 R10: 0000000000000014 R11: 0000000000000000 R12: ffffa04e92e92100 R13: 0000000000000001 R14: ffffa04e92e92a00 R15: ffffa04e92e92a00 FS: 0000000000000000(0000) GS:ffffa0508f600000(0000) knlGS:0000000000000000 i915 0000:00:02.0: vblank wait timed out on crtc 0 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000198 CR3: 000000004460a001 CR4: 00000000001706f0 Call Trace: dev_hard_start_xmit+0xc7/0x1e0 sch_direct_xmit+0x10f/0x310 Cc: # 4.9+ Fixes: bc2bebe8de8e ("alx: remove WoL support") Reported-by: Zbynek Michl Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983595 Signed-off-by: Jakub Kicinski Tested-by: Zbynek Michl Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/atheros/alx/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/atheros/alx/main.c +++ b/drivers/net/ethernet/atheros/alx/main.c @@ -1897,13 +1897,16 @@ static int alx_resume(struct device *dev if (!netif_running(alx->dev)) return 0; - netif_device_attach(alx->dev); rtnl_lock(); err = __alx_open(alx, true); rtnl_unlock(); + if (err) + return err; + + netif_device_attach(alx->dev); - return err; + return 0; } static SIMPLE_DEV_PM_OPS(alx_pm_ops, alx_suspend, alx_resume);