From nobody Sat Nov 23 08:40:26 2024 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77419200C95; Wed, 13 Nov 2024 11:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496428; cv=none; b=bD2dL+YNkAp6Ix9r7laY2G++XBrjjr8JHeZEX16zwrpPXhR89L4VavYFt7cU3M8y8cAvFvGPMtr6z56PLyImx5c7LM0YQ0/uTif+ZOgqWffNWi2pUXeeaFcd0Bml9S9EMmHr74voYG/nYIpkIw4yMUd0gUFplNO3VpjL1mKVuDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496428; c=relaxed/simple; bh=mgeBw3UfjWrFpxqOauct6irHUI45weMx4yTLRTrcxUE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MQ1s66T9TorBYq3/vj5fQtVBz0RpwxUzqMAx4nUKak2Nq62qmYymxjDavf1u4VYM5L3hjSf6c2sRJXwQHc2SXMoI5RvNoBG5RhBwFml2e1StdTaebsnjFZO9QjvHEEQNL0PbEkQi5CQocnqgBRyXQQ/8CfHs0ZR8rO2y+zGDcgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=LHLWmUsr; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="LHLWmUsr" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AD9Avi7004399; Wed, 13 Nov 2024 03:13:25 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=A 21x6UKq40vBWyAGfY0XuZoMJ5czzxDqvdLvujUD+CY=; b=LHLWmUsr/zJE/bi38 Ut/pDACHuU8Wvg2hxZiNGe75CY0wb+ViHWu08lD4Ql/J5fvndglvxLykM+fgj6PP 91+yH9W+r+n82qeFCSHrBH5XxEhlf9uKtr8/cfBcXrmsjWF0LmWZmVozInBwU3Zx 2uXqZInSM3dA17qR0V+a0S+4Q1xnfBC26GpTuWzAwbFJhHurr/Z4S7JOdNxZWeCp wCHMtxjn5z0Qi6PRnx849E48s9xgUcdefhsvWu4EIVD/Bk0+zbLz2zn36pd7BUfn oGFSHGCbGijOFFp0NGZy5kexgzGJ41o4hTt0ObcbLo/YQnvTHKzUVk8NHOwo77cI Y7b6g== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42vs8g06dc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 03:13:25 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 13 Nov 2024 03:13:24 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 13 Nov 2024 03:13:24 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id B84443F7040; Wed, 13 Nov 2024 03:13:23 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Abhijit Ayarekar , Satananda Burla Subject: [PATCH net v4 1/7] octeon_ep: Add checks to fix double free crashes Date: Wed, 13 Nov 2024 03:13:13 -0800 Message-ID: <20241113111319.1156507-2-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113111319.1156507-1-srasheed@marvell.com> References: <20241113111319.1156507-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: H-XZc3n7iDDvzsPE4v0m6XqdrQs7gfyk X-Proofpoint-ORIG-GUID: H-XZc3n7iDDvzsPE4v0m6XqdrQs7gfyk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" From: Vimlesh Kumar Add required checks to avoid double free. Crashes were observed due to the same on reset scenarios, when reset was tried multiple times, and the first reset had torn down resources already. Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support= ") Signed-off-by: Vimlesh Kumar Signed-off-by: Shinas Rasheed --- V4: - Removed unnecessary protective code. Added fast return from octep_free_irqs() - Improved commit message V3: https://lore.kernel.org/all/20241108074543.1123036-2-srasheed@marvell.c= om/ - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-2-srasheed@marvell.c= om/ - No changes V1: https://lore.kernel.org/all/20241101103416.1064930-2-srasheed@marvell.c= om/ .../net/ethernet/marvell/octeon_ep/octep_main.c | 14 ++++++++++---- drivers/net/ethernet/marvell/octeon_ep/octep_tx.c | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/= net/ethernet/marvell/octeon_ep/octep_main.c index 549436efc204..29796544feb6 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -496,6 +496,9 @@ static void octep_free_irqs(struct octep_device *oct) { int i; =20 + if (!oct->msix_entries) + return; + /* First few MSI-X interrupts are non queue interrupts; free them */ for (i =3D 0; i < CFG_GET_NON_IOQ_MSIX(oct->conf); i++) free_irq(oct->msix_entries[i].vector, oct); @@ -505,7 +508,7 @@ static void octep_free_irqs(struct octep_device *oct) for (i =3D CFG_GET_NON_IOQ_MSIX(oct->conf); i < oct->num_irqs; i++) { irq_set_affinity_hint(oct->msix_entries[i].vector, NULL); free_irq(oct->msix_entries[i].vector, - oct->ioq_vector[i - CFG_GET_NON_IOQ_MSIX(oct->conf)]); + oct->ioq_vector[i - CFG_GET_NON_IOQ_MSIX(oct->conf)]); } netdev_info(oct->netdev, "IRQs freed\n"); } @@ -635,8 +638,10 @@ static void octep_napi_delete(struct octep_device *oct) =20 for (i =3D 0; i < oct->num_oqs; i++) { netdev_dbg(oct->netdev, "Deleting NAPI on Q-%d\n", i); - netif_napi_del(&oct->ioq_vector[i]->napi); - oct->oq[i]->napi =3D NULL; + if (oct->oq[i]->napi) { + netif_napi_del(&oct->ioq_vector[i]->napi); + oct->oq[i]->napi =3D NULL; + } } } =20 @@ -666,7 +671,8 @@ static void octep_napi_disable(struct octep_device *oct) =20 for (i =3D 0; i < oct->num_oqs; i++) { netdev_dbg(oct->netdev, "Disabling NAPI on Q-%d\n", i); - napi_disable(&oct->ioq_vector[i]->napi); + if (oct->oq[i]->napi) + napi_disable(&oct->ioq_vector[i]->napi); } } =20 diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c b/drivers/ne= t/ethernet/marvell/octeon_ep/octep_tx.c index 06851b78aa28..157bf489ae19 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c @@ -323,6 +323,8 @@ void octep_free_iqs(struct octep_device *oct) int i; =20 for (i =3D 0; i < CFG_GET_PORTS_ACTIVE_IO_RINGS(oct->conf); i++) { + if (!oct->iq[i]) + continue; octep_free_iq(oct->iq[i]); dev_dbg(&oct->pdev->dev, "Successfully destroyed IQ(TxQ)-%d.\n", i); --=20 2.25.1 From nobody Sat Nov 23 08:40:26 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C65231FEFC8; Wed, 13 Nov 2024 11:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496424; cv=none; b=OQ9SvpBIOqMyWas1ygT7THcetDfNsYHP013AyQu2ixo/GHYzB3wOP+ow418dvvXGSPf+V2ZUGB3ly2KiLATqITjeKD544Srf36xqAg8BuOkoRQsRFrLJV+ckFBt45Yz93JV67/I11/U8Q4vffMDHFyZ2XZwTXSVbOBeBnatApFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496424; c=relaxed/simple; bh=MwdtHh/UdhLoNVhfaMc2nF6UrHhs/5DLwVhQU1QNX3s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vDRMGNqX+2AfoAAlxj59cEurwNVJ1rrq9Dzldovq/PFRhhTCRqkv/giz+l0TJxjBz6xcZeOuzqhrCHA/Ykbzpuc6reuV1msYMacyMoE5ksZnIAqQRKG9gMBEU/X9YrDYE/3DqNcSdonYQZZ5Bwmf0P0jW0uKJpazzQ0lr6qV+1A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=R02wgCr2; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="R02wgCr2" Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AD8WPYB001685; Wed, 13 Nov 2024 03:13:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=M 9c3vgHxrcorH42bwjyISL3+E2/jASHcL8EdxTbUmxw=; b=R02wgCr22stgHH76E rYTcqZ0nzUbBLPI5b7ZIUqUK5NYYi70D9/AGgecR2gye3jP5r1pqXJepM80F+zXY VP1K74lmMSh/vzOeB+F35pRqRqnKfUPx43ogksIWmv+YDKTxrXxqTcnoNPuzt6jv d930aN6/WaRqtRISbbrnrC/z+tKXInGbMijeFhlhUFSxSyCnrpn3y6/DZTXkxOQt IhHZJkiuBPmEO57P8J0ve00hAVea+gdkV8uUKFfpVQT5rExFwOPopezlNbx4F3Td a9Po4fPBSNl285BH1C8bom4jlcvoO+5IJzsi9AHR9OnUbmoo8yvB5QR9JZyb3RoE PnhPA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42v5s2tqff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 03:13:27 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 13 Nov 2024 03:13:25 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 13 Nov 2024 03:13:25 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 7A67F3F7040; Wed, 13 Nov 2024 03:13:25 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Abhijit Ayarekar , Satananda Burla Subject: [PATCH net v4 2/7] octeon_ep: Fix null dereferences to IQ/OQ pointers Date: Wed, 13 Nov 2024 03:13:14 -0800 Message-ID: <20241113111319.1156507-3-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113111319.1156507-1-srasheed@marvell.com> References: <20241113111319.1156507-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: 0QeGa7ySTxn2oklJq1rQwkyFv-XAfxal X-Proofpoint-ORIG-GUID: 0QeGa7ySTxn2oklJq1rQwkyFv-XAfxal X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 Content-Type: text/plain; charset="utf-8" During unload, sometimes race scenarios are seen wherein the get stats callback proceeds to retrieve the IQ/OQ stats, but by then the IQ/OQ might have been already freed. Protect against such conditions by defensively checking if the IQ/OQ pointers are null before dereference. Fixes: 6a610a46bad1 ("octeon_ep: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V4: - No change V3: https://lore.kernel.org/all/20241108074543.1123036-3-srasheed@marvell.c= om/ - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-3-srasheed@marvell.c= om/ - Split from earlier patch into a separate patch - Added more context V2: https://lore.kernel.org/all/20241101103416.1064930-3-srasheed@marvell.c= om/ drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/= net/ethernet/marvell/octeon_ep/octep_main.c index 29796544feb6..3cea7811e48d 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -1015,6 +1015,9 @@ static void octep_get_stats64(struct net_device *netd= ev, struct octep_iq *iq =3D oct->iq[q]; struct octep_oq *oq =3D oct->oq[q]; =20 + if (!iq || !oq) + return; + tx_packets +=3D iq->stats.instr_completed; tx_bytes +=3D iq->stats.bytes_sent; rx_packets +=3D oq->stats.packets; --=20 2.25.1 From nobody Sat Nov 23 08:40:26 2024 Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53945201007; Wed, 13 Nov 2024 11:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496430; cv=none; b=Ap1484bbuGEs3s+QSUK08n2OdkosSS+axqj6RW1CETn9Derr1BzOSfL7rmIFXsQ93x6UMyLz780MLiGNkFZwSTcRdARldW1z+9Kjxk+GGksNP7BOVW4IKFwkVSDkVAWDGVEdjUzhif8OisuJTYOmizIqoZLl1JhARMh1CD6An+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496430; c=relaxed/simple; bh=WbTzFStCX8oPnpzOiNOrdD9gK7rgoe1InOSFbEBB6eI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GoStyBhLueMbuGMTpG24Z/R27BX+aI86gJDNxjsZaiL4ND+NJIS5+FzDNHjD0keXMjFDZbFhD8W+eAyWiO9U0tG10BTPoXzk4YYHBrLLbEFaC0nvrvzS5ARfGhe6afEl2ENIOURqWho52lgVYkvBVCtckmvHatg5nAkt6LBFhJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=TsyGJGcY; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="TsyGJGcY" Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AD6X0Zd016637; Wed, 13 Nov 2024 03:13:29 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=C hbF4K2Kwyhx+BtI3fHlj2W8yCDcrWUeKdZbLjKj5vQ=; b=TsyGJGcYBWcYTcShW fcpTJo4OQuHIw5o/bvIXi/QbnnPFWjN0AxGAwsllaxivu/P6PyEHzSE7MUSaw3dG /TgL8WLuCHFObbhi59aiEPZdGy7y+CGrZdAlVBwdqr40ZPhJtkT7EdYrfOQBrGh/ kjeLyUFKYTDjf7eye99ICBziSCEG3VedN+tAHEYJrTvt2fO4V/PvlKeKSX8HgC9z zne6o/dY36nWRCrSn9iJBkAl7IOcVcoZBplIR++iRZxHTJyDv+dHFALt+q2WhlAm EBY+qgETpQ+WmOvKcq3e/MpLH85dPbBF+CBRtv+3xaV0zHA7RuV2i1wboyh8ADv7 3R/5A== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42vpxp0ftp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 03:13:28 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 13 Nov 2024 03:13:27 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 13 Nov 2024 03:13:27 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 1CF8D3F7040; Wed, 13 Nov 2024 03:13:27 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Satananda Burla , "Abhijit Ayarekar" Subject: [PATCH net v4 3/7] octeon_ep: add protective null checks in napi callbacks for cn9k cards Date: Wed, 13 Nov 2024 03:13:15 -0800 Message-ID: <20241113111319.1156507-4-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113111319.1156507-1-srasheed@marvell.com> References: <20241113111319.1156507-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: Qx8SQPnIqJdlODiIuBOk6G1KfkmRTqFr X-Proofpoint-ORIG-GUID: Qx8SQPnIqJdlODiIuBOk6G1KfkmRTqFr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 Content-Type: text/plain; charset="utf-8" During unload, at times the OQ parsed in the napi callbacks have been observed to be null, causing system crash. Add protective checks to avoid the same, for cn9k cards. Fixes: 1f2c2d0cee02 ("octeon_ep: add hardware configuration APIs") Signed-off-by: Shinas Rasheed --- V4: - No changes V3: https://lore.kernel.org/all/20241108074543.1123036-4-srasheed@marvell.c= om/ - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-4-srasheed@marvell.c= om/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-3-srasheed@marvell.c= om/ drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c b/drive= rs/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c index b5805969404f..b87336b2e4b9 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c @@ -617,7 +617,14 @@ static irqreturn_t octep_rsvd_intr_handler_cn93_pf(voi= d *dev) static irqreturn_t octep_ioq_intr_handler_cn93_pf(void *data) { struct octep_ioq_vector *vector =3D (struct octep_ioq_vector *)data; - struct octep_oq *oq =3D vector->oq; + struct octep_oq *oq; + + if (!vector) + return IRQ_HANDLED; + oq =3D vector->oq; + + if (!oq || !(oq->napi)) + return IRQ_HANDLED; =20 napi_schedule_irqoff(oq->napi); return IRQ_HANDLED; --=20 2.25.1 From nobody Sat Nov 23 08:40:26 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACAAA200130; Wed, 13 Nov 2024 11:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496426; cv=none; b=Tv4DFNMr3vECGkZuN+ZD6PetjAEz3maiX9Pazn6p7Oznu0Cm9yO+7JcivbfD2UQ+uPUUjRvTlshD0VXAmHqGgu897KIQy48eCSBR/XBSSPEgmn3oe/3tHGp98pdv9xpgVjtIZexUA3x/geJ30LpufCe0TwRATuKCLORccsk4wp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496426; c=relaxed/simple; bh=0NKxQZ2eJIO94As+SZU5UQtSG1PepPeFOGfQrt2dgVs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tQ9AezGKbGVHeMyEGu+QQrtQYZfvaQZd8/OorB1kAEiCgAVrzspmAB1RPWqjSuq4XUDqY/W/hyeeKFBeekHCgBo933FYPhWb0XuCA9A0wg9727LdQUEUHlir3Zsv3jhzAAqnvjSz3hbTmXXKJ5WOZjLDcnFKA4VPIuLbJ2eAVhs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=SE36dAjP; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="SE36dAjP" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACFpGYn025821; Wed, 13 Nov 2024 03:13:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=J YHP6zG5isnC7ZyUgogxd68rMkjJZJLPn6DZH60CfeI=; b=SE36dAjPMX76sOPRL XTiwvXUp4+L2lRJebOqZaf+B98Zrc94syjQP4NROvTpvKvfadMwCn1dQeFrXnBkb QvtRTk7dHAuUx1ylOQUEMoY9aOpvLRZT19AwNZfdlzZzI/3JSQELOYHGy3fPpi3k zq6dtUwtu0nnNPRW9wJEJa1Qc+Ckyn9v3rRnL4tAforrgkCW5gLXE/DHT9WMDkML p9NkzLPvIlONbDtT91AIMJJ83IwFAEXZkWrvi0k3ltDuku2LPppttW2iRDUolgTD KelCB/QVE1vHkGkMjn91yJpIvKdOiVcTiZ66e4HTWmKNYjbPLy4NXmSv86X7GER/ wlZPA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42va1625t9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 03:13:30 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 13 Nov 2024 03:13:29 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 13 Nov 2024 03:13:29 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id D10713F7040; Wed, 13 Nov 2024 03:13:28 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" Subject: [PATCH net v4 4/7] octeon_ep: add protective null checks in napi callbacks for cnxk cards Date: Wed, 13 Nov 2024 03:13:16 -0800 Message-ID: <20241113111319.1156507-5-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113111319.1156507-1-srasheed@marvell.com> References: <20241113111319.1156507-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: aYUyXPW9LrQJwvFJ08AOKbKKvZpqgI-G X-Proofpoint-ORIG-GUID: aYUyXPW9LrQJwvFJ08AOKbKKvZpqgI-G X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" During unload, at times the OQ parsed in the napi callbacks have been observed to be null, causing system crash. Add protective checks to avoid the same, for cnxk cards. Fixes: 0807dc76f3bf ("octeon_ep: support Octeon CN10K devices") Signed-off-by: Shinas Rasheed --- V4: - No Changes V3: https://lore.kernel.org/all/20241108074543.1123036-5-srasheed@marvell.c= om/ - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-5-srasheed@marvell.c= om/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-3-srasheed@marvell.c= om/ drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c b/drive= rs/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c index 5de0b5ecbc5f..65a8dc1d492b 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c @@ -638,7 +638,14 @@ static irqreturn_t octep_rsvd_intr_handler_cnxk_pf(voi= d *dev) static irqreturn_t octep_ioq_intr_handler_cnxk_pf(void *data) { struct octep_ioq_vector *vector =3D (struct octep_ioq_vector *)data; - struct octep_oq *oq =3D vector->oq; + struct octep_oq *oq; + + if (!vector) + return IRQ_HANDLED; + oq =3D vector->oq; + + if (!oq || !(oq->napi)) + return IRQ_HANDLED; =20 napi_schedule_irqoff(oq->napi); return IRQ_HANDLED; --=20 2.25.1 From nobody Sat Nov 23 08:40:26 2024 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A21B201107; Wed, 13 Nov 2024 11:13:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496432; cv=none; b=l+kqZ+MypGQIzNi6xqLkYGUEfO/nXbwMgPOujNsIcUUfHlt4ZDjnGmBhxiiF6qOkHjzGF+1QOo6bNmzRlDvnjZVNSG1yzYRmhA+/E69mbrFlwTreV6Xra0ByrDahTO0LT9MW1/G17Z5WfxdPQuI3EO2zDzRI8DxIKseTZUELYo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496432; c=relaxed/simple; bh=Kcv9vW/h+pRyUCOwyvm4I27brOJxtSd+K9TD2MRq2WI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X0JZqLSBNqzSc1j4hUXufKokxV1fVS6lwIEi6u2kaiG2vl6FspLyXLImCDlDrjIj/PTmdPBysYWg/SzGXjtXFuYhgI7QQm6/Mv95tchaOo3hWqMsqiKoPVho6kEPCA9+X3uBGlwY04Sb1rVeFXRHoHGUnmgxR4WI4rI0j+C3buE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=PIjkO8xO; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="PIjkO8xO" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AD9Avi8004399; Wed, 13 Nov 2024 03:13:32 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=K F2s5RfoDycLzT2yfVRC3OhmwODgdcdCut7RX5aUXlA=; b=PIjkO8xOsqzNo484R rL+HBlWDo7bhbSiWFjJpBark+0lxgL9aTlSMnKHPrU+tN0iiiboAoI/OZ8iLQ8Z8 UTBMUEBfhT5X+mhiuY85/U8nQX7F2O5Eg2hMOx9pMhFxaXsRV2snEGrmPP3voSVc Aqx2N2ZCUYI4eKInxgKguqRJdSQZIomOxcD5dNftg9sgF/qK43ru+kg/eMT2n+5S Xzi3PYOEOyPj8P96As31SyEwt3IDdEAl9maFyMCETNZEN8iIMaFIBQZgGyBcyK9a 4DFhIIo3WFKnu7qySvYkUdqUZuHGfDQ7Fefh+F+JpMcrUhv35g1NKLV+8rnxR5t0 dKRsg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42vs8g06dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 03:13:32 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 13 Nov 2024 03:13:30 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 13 Nov 2024 03:13:30 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 87A5A3F7040; Wed, 13 Nov 2024 03:13:30 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v4 5/7] octeon_ep_vf: Fix null dereferences to IQ/OQ pointers Date: Wed, 13 Nov 2024 03:13:17 -0800 Message-ID: <20241113111319.1156507-6-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113111319.1156507-1-srasheed@marvell.com> References: <20241113111319.1156507-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: DA1GuFKul9rV9QWxxtoBZTNY0TASVl0S X-Proofpoint-ORIG-GUID: DA1GuFKul9rV9QWxxtoBZTNY0TASVl0S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" During unload, sometimes race scenarios are seen wherein the get stats callback proceeds to retrieve the IQ/OQ stats, but by then the IQ/OQ might have been already freed. Protect against such conditions by defensively checking if the IQ/OQ pointers are null before dereference. Fixes: cb7dd712189f ("octeon_ep_vf: Add driver framework and device initial= ization") Signed-off-by: Shinas Rasheed --- V4: - No Changes V3: https://lore.kernel.org/all/20241108074543.1123036-6-srasheed@marvell.c= om/ - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-6-srasheed@marvell.c= om/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-4-srasheed@marvell.c= om/ drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c b/dr= ivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c index 7e6771c9cdbb..79d9ffd593eb 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c @@ -790,6 +790,9 @@ static void octep_vf_get_stats64(struct net_device *net= dev, struct octep_vf_iq *iq =3D oct->iq[q]; struct octep_vf_oq *oq =3D oct->oq[q]; =20 + if (!iq || !oq) + return; + tx_packets +=3D iq->stats.instr_completed; tx_bytes +=3D iq->stats.bytes_sent; rx_packets +=3D oq->stats.packets; --=20 2.25.1 From nobody Sat Nov 23 08:40:26 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 076B11FEFDE; Wed, 13 Nov 2024 11:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496424; cv=none; b=lgENysUphWtBwtAjTvteBkXn2byrhtgNJufRT82YMX21KC/yd9mixGmhAFdXrYfSttCdsBoEfhP2a8cXDGdZnQc11rkmVDXudxNC3rW9vMFmVY7QsI/9ch4Nm+J0KKHw9DaJ8pqZDYsqExwWr/6aTsakjH1PNEfsTsZcsHjjaYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496424; c=relaxed/simple; bh=A22PI+ae8ZVpaPRQ6udLcLq/Yyb1U1TYd8V4q0ZaOss=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BbNduyk+rg9af0uyd1U2c3xVfANLXw+DQwskK+XaJhk16wC4TtGfVIKNoVrJsqa5DLPe5pEhysw36mRDPeTVBVO3A5PRDtq+yYeSRRVLbiOH58aXesUDJ3mlUcOeq554cOAuvG7916JWCHwY49XQNJUPVm+lJHlyfUbpfkb+Xus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=AnE93TzW; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="AnE93TzW" Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AD8WPYD001685; Wed, 13 Nov 2024 03:13:34 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=c R+O8JlKd4NixP/9Jc5T8cC2dkX1tP9ZWb1hKV6/kSQ=; b=AnE93TzWBghSZMHpt JjjKg9+YoOcTeloK+W3yYieg0DhCKcquhTGemT/uHvUxRFMpgHiA4Xj5ugK5G495 hXec0+Ve/snJosXWxB0DaB69F9kJdLOREh6Wv1Wv0fFZBbQs9ehsmKCSbeA63rr3 FbIJ9ijuYz8QtIouUEFKpNrfSRyvDWfF3jQSrOdYy8fcsbGCLiDjk2U/ufXFNEkZ rEAoo6kwsDOyt6JDixIXMb6SKUnvYDOqTBr0SIisyRSNGDthJfvB+WcCrUGg10AB YaoayWUjnId8GvzNtMR5PJ60dPdpgYUqGtYfGhdlk8KhwwxDLw8YIrLulf5/FYt9 hIjEg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42v5s2tqfm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 03:13:34 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 13 Nov 2024 03:13:32 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 13 Nov 2024 03:13:32 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 5E9DF3F7040; Wed, 13 Nov 2024 03:13:32 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v4 6/7] octeon_ep_vf: add protective null checks in napi callbacks for cn9k cards Date: Wed, 13 Nov 2024 03:13:18 -0800 Message-ID: <20241113111319.1156507-7-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113111319.1156507-1-srasheed@marvell.com> References: <20241113111319.1156507-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: Ow5mM_CZBPQ62nHHw6rKGSkcdE_xTGFa X-Proofpoint-ORIG-GUID: Ow5mM_CZBPQ62nHHw6rKGSkcdE_xTGFa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 Content-Type: text/plain; charset="utf-8" During unload, at times the OQ parsed in the napi callbacks have been observed to be null, causing system crash. Add protective checks to avoid the same, for cn9k cards. Fixes: cb7dd712189f ("octeon_ep_vf: Add driver framework and device initial= ization") Signed-off-by: Shinas Rasheed --- V4: - No changes V3: https://lore.kernel.org/all/20241108074543.1123036-7-srasheed@marvell.c= om/ - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-7-srasheed@marvell.c= om/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-4-srasheed@marvell.c= om/ drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c b/dr= ivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c index 88937fce75f1..f1b7eda3fa42 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c @@ -273,8 +273,14 @@ static irqreturn_t octep_vf_ioq_intr_handler_cn93(void= *data) struct octep_vf_oq *oq; u64 reg_val; =20 - oct =3D vector->octep_vf_dev; + if (!vector) + return IRQ_HANDLED; + oq =3D vector->oq; + if (!oq) + return IRQ_HANDLED; + + oct =3D vector->octep_vf_dev; /* Mailbox interrupt arrives along with interrupt of tx/rx ring pair 0 */ if (oq->q_no =3D=3D 0) { reg_val =3D octep_vf_read_csr64(oct, CN93_VF_SDP_R_MBOX_PF_VF_INT(0)); --=20 2.25.1 From nobody Sat Nov 23 08:40:26 2024 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85638201018; Wed, 13 Nov 2024 11:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496430; cv=none; b=c9OwaiysulsmpAE5npXKYScsUtpHyf+N3PPmKRmeBWak77borzDCitNs5wCv6CA294Jzh1VRYDffP+g++wFWH4J+tWoWhCmsg5w4S1aEXRIYkCRhU1RK6Kj5HLtg/dqeur0ShoJjA7o12LmjnINCV3mMHUolmoo0L9xBYxj4wx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731496430; c=relaxed/simple; bh=nzv+y2yiu2Jrwr3CG+NaBctuNIWu3AdOb/rrEmRnA2U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q3fARauS0uU9pkPfEH6nnxGrzFU3KaSFI+KIZ6N+TZ0Gq7q1PzYut2+pkeiyKo4CHHOSKDHhCzXtfvI5IN65X3NlxJADkTYzDR+pbPQdW2uRUOkS79t1r7Av1tP5QVQH2wV8aSjsWKFo63H53mascKnwj7PyPNqYbNVEeTOxBtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=I1Li2e/F; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="I1Li2e/F" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AD9B2Al004423; Wed, 13 Nov 2024 03:13:35 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=t dDHPDl2Sti0NQvKVT75wfU6XVb6GbzwngwOqMiRso4=; b=I1Li2e/FhYZbhEA/6 GZHD53sG3ZF4SOmNzu97CeupEFJ9PTF+upFAz9t958eNx5VT6pNO4alZQQw3FMnH 2m6TYSbMH6oeIjV5U922EoR8sN8nVxATmtzfk0wgh1u7TiRANieSc34rCGjVHJG1 os9qwcTA3Y7FGTbDjCmHIBzer/MLduxVXAxpzq8hv30PIUz2EbJMkOdAPOpM7UD6 91ojN/9x15eDQs9JCD+5j8xVfhzlJA+zWlz63qFeGGhfgmdfW21Tgy/ABCC7kppT 4VaZEuMudREGgI/2j6ZwneXwgE8jvoKIQlC0EikArGOXD1lez5xbulv5SL7xohyO 7Wpag== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42vs8g06dk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 03:13:35 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 13 Nov 2024 03:13:34 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 13 Nov 2024 03:13:34 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 108333F7040; Wed, 13 Nov 2024 03:13:34 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v4 7/7] octeon_ep_vf: add protective null checks in napi callbacks for cnxk cards Date: Wed, 13 Nov 2024 03:13:19 -0800 Message-ID: <20241113111319.1156507-8-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113111319.1156507-1-srasheed@marvell.com> References: <20241113111319.1156507-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: oYsrxAmyJNl8A6s8uSTOgi9vOKbMVMLX X-Proofpoint-ORIG-GUID: oYsrxAmyJNl8A6s8uSTOgi9vOKbMVMLX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" During unload, at times the OQ parsed in the napi callbacks have been observed to be null, causing system crash. Add protective checks to avoid the same, for cnxk cards. Fixes: cb7dd712189f ("octeon_ep_vf: Add driver framework and device initial= ization") Signed-off-by: Shinas Rasheed --- V4: - No Changes V3: https://lore.kernel.org/all/20241108074543.1123036-8-srasheed@marvell.c= om/ - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-8-srasheed@marvell.c= om/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-4-srasheed@marvell.c= om/ .../ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c b/dr= ivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c index 1f79dfad42c6..31c0d7c0492a 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c @@ -284,8 +284,14 @@ static irqreturn_t octep_vf_ioq_intr_handler_cnxk(void= *data) struct octep_vf_oq *oq; u64 reg_val; =20 - oct =3D vector->octep_vf_dev; + if (!vector) + return IRQ_HANDLED; + oq =3D vector->oq; + if (!oq) + return IRQ_HANDLED; + + oct =3D vector->octep_vf_dev; /* Mailbox interrupt arrives along with interrupt of tx/rx ring pair 0 */ if (oq->q_no =3D=3D 0) { reg_val =3D octep_vf_read_csr64(oct, CNXK_VF_SDP_R_MBOX_PF_VF_INT(0)); @@ -294,6 +300,10 @@ static irqreturn_t octep_vf_ioq_intr_handler_cnxk(void= *data) octep_vf_write_csr64(oct, CNXK_VF_SDP_R_MBOX_PF_VF_INT(0), reg_val); } } + + if (!(oq->napi)) + return IRQ_HANDLED; + napi_schedule_irqoff(oq->napi); return IRQ_HANDLED; } --=20 2.25.1