Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2329323imm; Mon, 28 May 2018 06:10:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqwo/W4vNf+hnyIHmM6p9ulhnxR2VlNwPxxNUNcwP0Uu1vBGKQcuWMY2QsMMKtk5JlPPaIk X-Received: by 2002:a17:902:a5c7:: with SMTP id t7-v6mr13735812plq.360.1527513021308; Mon, 28 May 2018 06:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527513021; cv=none; d=google.com; s=arc-20160816; b=jC/Oga0WhfNJuAiXGYUxJU/RJW7/czKYlRORWNkVDdvqEpY92df1iSxYoq/ruknV82 YbxJ3/b0qoGYMmSaLSu/RyG2n0pg7ceHuOZxNSH2E8m1M9D/6RJIllmzE4eiYoO7M5cQ Qmd04GAw81I/RkfO5GWPAiNONwiaAYqTLaHmn5MQA1jIeDyr6KZk0wl0q3AsxOMfYwiN lx57yfMk/OlcKTSFYgrFCNepeTcjVjvnWLKlkHLhY6+/wmK8d9M3ogYJq8cxsySyy2QL 4j6jTrJ7d8zZtB87Lv/096774L/EBPjwokZCLsSnQLpnpjEVI4u/uYNZRkLwaFu6bcx4 5O2g== 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:dkim-signature :arc-authentication-results; bh=8nTpq3ooSnzifqWomheiy8M2i/hYe6UXV5P+50DJTZo=; b=MCgzBJCne1IsbA38e9VKaYpRScvfuN4yTmWxvYMkOuSstt4ngfOSDgLd3siqgclEN5 wfHUGlF5LaGrjw4h8e4Kj2rAfEiEUDJ4GtmebU6+hPFe+4+fmPHdPYNkMu5+WvIFX75k lOXzHcJinbLD5f6ClsMEoN/VkYS0Lt7dPCFaP/aoqt1Ph3hVaNqafVl6zEz/VsQx1LHa OWFEZDQ1CjCT0P4eEoFuoATTaabiEE/xn9tgXPY5Ki0GySxIRph/g/QoscWGiGaxJIPz vddaw+75V25WGeJL7I3E7KXc5I2/sgr36RQvnDFUaq7gbPZEmUBxJixT56ZThO8KuWBG r87g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=myycBpRV; 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 p11-v6si29480975pfh.249.2018.05.28.06.10.06; Mon, 28 May 2018 06:10:21 -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=myycBpRV; 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 S1163860AbeE1Kvn (ORCPT + 99 others); Mon, 28 May 2018 06:51:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:40936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163714AbeE1Kvb (ORCPT ); Mon, 28 May 2018 06:51:31 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4F82820883; Mon, 28 May 2018 10:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504690; bh=aJ5JAE8gz2sZheCBr177f/dkjQmxJP7tdr7NXqeOlCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=myycBpRVLXbjMGM9Pq5PLoLdZBTJhowCHIx9nCH62Nlaa36oNngjjyRelOAzSmnA4 A01gYHU2XBfXWPPrVgr8E2D2jjkGIB9tv3dJtyZbSGbpWGS4bQXbj2HMMHBvxhV9NK mJixrEecPncMDGOeMDGMN8Bfv64lQk6/k1QqkeVY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matt Sealey , Jeremy Linton , Andrew Lunn , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 229/496] net: smsc911x: Fix unload crash when link is up Date: Mon, 28 May 2018 12:00:14 +0200 Message-Id: <20180528100329.557355173@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@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: Jeremy Linton [ Upstream commit e06513d78d54e6c7026c9043a39e2c01ee25bdbe ] The smsc911x driver will crash if it is rmmod'ed while the netdev is up like: Call trace: phy_detach+0x94/0x150 phy_disconnect+0x40/0x50 smsc911x_stop+0x104/0x128 [smsc911x] __dev_close_many+0xb4/0x138 dev_close_many+0xbc/0x190 rollback_registered_many+0x140/0x460 rollback_registered+0x68/0xb0 unregister_netdevice_queue+0x100/0x118 unregister_netdev+0x28/0x38 smsc911x_drv_remove+0x58/0x130 [smsc911x] platform_drv_remove+0x30/0x50 device_release_driver_internal+0x15c/0x1f8 driver_detach+0x54/0x98 bus_remove_driver+0x64/0xe8 driver_unregister+0x34/0x60 platform_driver_unregister+0x20/0x30 smsc911x_cleanup_module+0x14/0xbca8 [smsc911x] SyS_delete_module+0x1e8/0x238 __sys_trace_return+0x0/0x4 This is caused by the mdiobus being unregistered/free'd and the code in phy_detach() attempting to manipulate mdio related structures from unregister_netdev() calling close() To fix this, we delay the mdiobus teardown until after the netdev is deregistered. Reported-by: Matt Sealey Signed-off-by: Jeremy Linton Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/smsc/smsc911x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -2335,14 +2335,14 @@ static int smsc911x_drv_remove(struct pl pdata = netdev_priv(dev); BUG_ON(!pdata); BUG_ON(!pdata->ioaddr); - WARN_ON(dev->phydev); SMSC_TRACE(pdata, ifdown, "Stopping driver"); + unregister_netdev(dev); + mdiobus_unregister(pdata->mii_bus); mdiobus_free(pdata->mii_bus); - unregister_netdev(dev); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smsc911x-memory"); if (!res)