Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3672771pxv; Mon, 26 Jul 2021 09:08:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkh2SJaPhe1hRiw4mfHxFJcm8Edr3urJnpJx4ABjsg+LBw8CMnXYwMzu0EGLkflIgcOV+Y X-Received: by 2002:a05:6402:1771:: with SMTP id da17mr22260418edb.23.1627315694939; Mon, 26 Jul 2021 09:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315694; cv=none; d=google.com; s=arc-20160816; b=JFbJW1AcpGb0Kpy9wm528dxw2I3cAyartLTffIYnx6emloBMqucRmxyrJitIvlwPvc 7nCh2OtVZr5xg/9SntD93OTJ2hTiy2I9MFUOWYAfcPtsXBf5CGzbrNdkWQbTLfYe+EiF dlU+2HGszkurXuMGCcfe2iSqxtbrMUqsDILfqciez9owb1sEAECTw2WsZP69h3p2ex8M v/qxsSuTztq+/NgBoWEQLDo5pTBC1MIMVouvfczxdHxIwTB3EMmDl+psSu+YmA0HyVcp L4hr/bxmJSVvOZiWnKkUpAAojYIESvd6d5Dr1VC3TLFN/B5285Ka+8VDXzh1THAXLfap lrEg== 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=cUZ8sOGtTvmXvaWkaC2o7iId9zOcH1BCE4N8MjYMOok=; b=Gw/4zSPinVNMeRXaDSQqrIgW+SErII379/AvnIVphh0EaHQ9zGxNnpwzgW0lYBBEoR ElxstsVx2MCaCumMKVLRtCz43GfumwvgQtwfrZgE7nxARj+STY/pIlh9AoV8qJoZwMfY CNKS03h3FatgdkE7Klrcl8KfjWExQQQD12FRWvqBbwJ/MJdlM6aZa5hnaXO/N7mFaf3H bcYwJc3w4CNQJ3ooDQ8CYKzde0QEBzwtO7Ev9Dc9k9zcH5UBSXuyKDCzzu2Hrh5uTuqq L2awoIH+r+JK2iAlXqeAWrWMcAwpEp7Zr6L6qDuyuURfiY25nFezPaXdEMoJ6C+jABhl prIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zfl9RBV1; 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 r16si351753edd.40.2021.07.26.09.07.51; Mon, 26 Jul 2021 09:08:14 -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=zfl9RBV1; 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 S237740AbhGZPYG (ORCPT + 99 others); Mon, 26 Jul 2021 11:24:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:55332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237429AbhGZPPp (ORCPT ); Mon, 26 Jul 2021 11:15:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B2DDD6103A; Mon, 26 Jul 2021 15:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314915; bh=F7gFp9qI89Abc2fahNFodiNrBz2NiAJG9mFSs5TYVco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zfl9RBV1q54h87KT/N5ZZ2L/l8dJ4Nx6yncmpPt02QQMXwODjHu0x5gcbKIpV8h4v 3oXXAUNKs5PNTKb9W+hmsjh6xtP7EjA1PNtZUij8I8YV5eB4bf0OS3AVuxxagkWlWz /lImHxAd+D5krwbx+pjUuhJiRXWd1E0CnX1jjWlQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shahjada Abul Husain , Raju Rangoju , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 018/108] cxgb4: fix IRQ free race during driver unload Date: Mon, 26 Jul 2021 17:38:19 +0200 Message-Id: <20210726153832.278019341@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@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: Shahjada Abul Husain [ Upstream commit 015fe6fd29c4b9ac0f61b8c4455ef88e6018b9cc ] IRQs are requested during driver's ndo_open() and then later freed up in disable_interrupts() during driver unload. A race exists where driver can set the CXGB4_FULL_INIT_DONE flag in ndo_open() after the disable_interrupts() in driver unload path checks it, and hence misses calling free_irq(). Fix by unregistering netdevice first and sync with driver's ndo_open(). This ensures disable_interrupts() checks the flag correctly and frees up the IRQs properly. Fixes: b37987e8db5f ("cxgb4: Disable interrupts and napi before unregistering netdev") Signed-off-by: Shahjada Abul Husain Signed-off-by: Raju Rangoju Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 18 ++++++++++-------- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index deb1c1f30107..21414a34a5b5 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -2245,6 +2245,9 @@ static void detach_ulds(struct adapter *adap) { unsigned int i; + if (!is_uld(adap)) + return; + mutex_lock(&uld_mutex); list_del(&adap->list_node); @@ -6152,10 +6155,13 @@ static void remove_one(struct pci_dev *pdev) */ destroy_workqueue(adapter->workq); - if (is_uld(adapter)) { - detach_ulds(adapter); - t4_uld_clean_up(adapter); - } + detach_ulds(adapter); + + for_each_port(adapter, i) + if (adapter->port[i]->reg_state == NETREG_REGISTERED) + unregister_netdev(adapter->port[i]); + + t4_uld_clean_up(adapter); adap_free_hma_mem(adapter); @@ -6163,10 +6169,6 @@ static void remove_one(struct pci_dev *pdev) cxgb4_free_mps_ref_entries(adapter); - for_each_port(adapter, i) - if (adapter->port[i]->reg_state == NETREG_REGISTERED) - unregister_netdev(adapter->port[i]); - debugfs_remove_recursive(adapter->debugfs_root); if (!is_t4(adapter->params.chip)) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c index 86b528d8364c..971bdd70b6d6 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c @@ -638,6 +638,9 @@ void t4_uld_clean_up(struct adapter *adap) { unsigned int i; + if (!is_uld(adap)) + return; + mutex_lock(&uld_mutex); for (i = 0; i < CXGB4_ULD_MAX; i++) { if (!adap->uld[i].handle) -- 2.30.2