From patchwork Thu Nov 12 00:31:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 324148 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp889669ils; Wed, 11 Nov 2020 17:50:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLFN1HrOfgKMH7LPZ8BRWiMow754FyN/P4fz1n7zTGvv9b64qyO5+OQ4TOphagIeVnn0r3 X-Received: by 2002:a17:906:415a:: with SMTP id l26mr27283130ejk.442.1605145817877; Wed, 11 Nov 2020 17:50:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605145817; cv=none; d=google.com; s=arc-20160816; b=RwDf+XIE/xvCKPib35wZghp0HesWxN9lOYJ2v8p4Z65xvciibpHlgSeLUEkpg3qzbA jM22LYfWq90IbWWGtRa/6XKaMD3rIZ1W4fxKaBHICEneyFeUgWW3uYNx9ndgYCpfB8q/ Vvp9Anv/p5oKUrVM5301mLURIxuT+dLiN2YtynYF68e738CcX6ieURBmpbWi6C9LTrHY SYdnqdO8BG47/BPijbcqaWCDBzKkiByWbQgJlboat/jbsW7d6dKoJtQWMEKbFG+4jleX 86l4dxtrZgmg8cIKzd6AMD7pGOi8NNp0aJz11HWzs46uHw5l6FmBLamkgwYv0ZwbtJUA BpmQ== 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 :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=B0ijZH9WOpOwBydvyI7ySw7yOS/FuDO5HArvaoRAty8=; b=uPdp0RVhMAqdr39EhIud7N0opQ03MQPFVboa2D6myY0C/FX/ed+tM4TOaqV4r1z7jh 01fMc6BpKSfysN+qe2Pba9TaIkD0BGe+YwY3iCgt2broZOj8dcINQDxvwLFuqyUpR3sR hhoJcMF7YtItfxHACG5XvxsvyD/BSSBiUna7gwXgwTlfvNiqOf/FV0tk9idHvyCogoNk Yo3SJAnNZK3KdN1ZEI7rXUEB9d520NpGJVLoRIRtGzN2RYgFh2VFDgy7/2xHafAaFPJ6 ZeN/q+id6e6y9kjgq9bZPXj4yANXiq+m5KyR8urnQTUFaNnRlnEUc8L8DS4e1PdMpovd zYXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="F/SzlSU8"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z41si2960127ede.375.2020.11.11.17.50.17; Wed, 11 Nov 2020 17:50:17 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-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=@gmail.com header.s=20161025 header.b="F/SzlSU8"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbgKLBc2 (ORCPT + 8 others); Wed, 11 Nov 2020 20:32:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728070AbgKLAb4 (ORCPT ); Wed, 11 Nov 2020 19:31:56 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 393B1C0617A6 for ; Wed, 11 Nov 2020 16:31:56 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id w6so2893517pfu.1 for ; Wed, 11 Nov 2020 16:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B0ijZH9WOpOwBydvyI7ySw7yOS/FuDO5HArvaoRAty8=; b=F/SzlSU85MJJzVyrlpu4g+UMfRiwoNFEUh6AUgdFndSk9OnGcoYwvjlvTc90aaGfBb 5ujeZqCkK1cF22KpLNBPRXjEDev0/1zJj//u2IgFTUot64xIqbfsAMmnOYBL6cxnlJR4 PecAVGfakNiIK8AeQaS1xnCgJ3tmbvvkLJruxnM/5IKSruqNrYHqW583VA4EA0p5L+FS G2racKiwGOr+fV0dSs4Qx0uqKvOfjoJ67rb83/UD4dTkVPWml0WQztxW+hFb/OSIQ8DW RCmi+5HcAj5BRkt5U5f+lRCM9ikBa/D2ROODkhBwg6CNArM7NdjDu0AQPuJBGAJUT85y iCcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=B0ijZH9WOpOwBydvyI7ySw7yOS/FuDO5HArvaoRAty8=; b=EMyvCIOj1zJIO9ffyY7k+n2D57isu89SShqgGAhr5g+yNl3WHOZ2CRfsLVuJESfbjk NIa6CB+3NZk//SpHvWtnwy23T/2EGhgTW0MyWfU/L94zg69J2xBtV3NLXicYqOyNtBEI /8Ws8EH4SQEZrueBO3tUfsJUnTA9fMoWV+/KtwFskDeXOtR4Hory5eV3HzYp442D79GJ DL2jl2xxFG7UH+qYTn4xhRYesRq5Es4sreb9BM8812Y9qKr6+0bSdiFNU75GqE0G21tM +kz01C5APCkjUYR4cCxVhZLpxjGWraD8E9DMGMAxHNPtljbr9Dsd1omJgD7tW8ywdQKG HWmw== X-Gm-Message-State: AOAM531LO43RgfG/UbJ18EINy4WWeYlB4YvxZMNsDW8W53TFjXUelKp3 m+xh7usI12B0v77sI5dSnoA= X-Received: by 2002:a63:3c10:: with SMTP id j16mr3242669pga.140.1605141115680; Wed, 11 Nov 2020 16:31:55 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id y19sm3889067pfn.147.2020.11.11.16.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 16:31:53 -0800 (PST) Sender: "joel.stan@gmail.com" From: Joel Stanley To: Jakub Kicinski , "David S . Miller" Cc: Andrew Jeffery , Ivan Mikhaylov , netdev@vger.kernel.org Subject: [PATCH] net: ftgmac100: Fix crash when removing driver Date: Thu, 12 Nov 2020 11:01:45 +1030 Message-Id: <20201112003145.831169-1-joel@jms.id.au> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When removing the driver we would hit BUG_ON(!list_empty(&dev->ptype_specific)) in net/core/dev.c due to still having the NC-SI packet handler registered. # echo 1e660000.ethernet > /sys/bus/platform/drivers/ftgmac100/unbind ------------[ cut here ]------------ kernel BUG at net/core/dev.c:10254! Internal error: Oops - BUG: 0 [#1] SMP ARM CPU: 0 PID: 115 Comm: sh Not tainted 5.10.0-rc3-next-20201111-00007-g02e0365710c4 #46 Hardware name: Generic DT based system PC is at netdev_run_todo+0x314/0x394 LR is at cpumask_next+0x20/0x24 pc : [<806f5830>] lr : [<80863cb0>] psr: 80000153 sp : 855bbd58 ip : 00000001 fp : 855bbdac r10: 80c03d00 r9 : 80c06228 r8 : 81158c54 r7 : 00000000 r6 : 80c05dec r5 : 80c05d18 r4 : 813b9280 r3 : 813b9054 r2 : 8122c470 r1 : 00000002 r0 : 00000002 Flags: Nzcv IRQs on FIQs off Mode SVC_32 ISA ARM Segment none Control: 00c5387d Table: 85514008 DAC: 00000051 Process sh (pid: 115, stack limit = 0x7cb5703d) ... Backtrace: [<806f551c>] (netdev_run_todo) from [<80707eec>] (rtnl_unlock+0x18/0x1c) r10:00000051 r9:854ed710 r8:81158c54 r7:80c76bb0 r6:81158c10 r5:8115b410 r4:813b9000 [<80707ed4>] (rtnl_unlock) from [<806f5db8>] (unregister_netdev+0x2c/0x30) [<806f5d8c>] (unregister_netdev) from [<805a8180>] (ftgmac100_remove+0x20/0xa8) r5:8115b410 r4:813b9000 [<805a8160>] (ftgmac100_remove) from [<805355e4>] (platform_drv_remove+0x34/0x4c) Fixes: bd466c3fb5a4 ("net/faraday: Support NCSI mode") Signed-off-by: Joel Stanley --- drivers/net/ethernet/faraday/ftgmac100.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.28.0 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index 983b6db2d80d..4edccba5e2a8 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -1945,6 +1945,8 @@ static int ftgmac100_remove(struct platform_device *pdev) netdev = platform_get_drvdata(pdev); priv = netdev_priv(netdev); + if (priv->ndev) + ncsi_unregister_dev(priv->ndev); unregister_netdev(netdev); clk_disable_unprepare(priv->rclk);