From nobody Thu Sep 24 14:25:57 2026 Received: from relay.smtp-ext.broadcom.com (lpdvsmtp12.broadcom.com [192.19.144.207]) (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 A621F55D89C; Tue, 22 Sep 2026 22:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.144.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115454; cv=none; b=mVV4XiAHRACEGIYWBr5cZw9NL67Whx44QcEi7D3QpFNPcYF3Q4YStj9Lz2AnM6hO5iAiur8y9yATro6MS/QyrPmwKuSvVRPTywV3Go6VFnc0hVzo5waHBbb3n1di/BWE5F1zOyPd8WTywGmzdjWc4vzEEgaWLx2VH6Cu14l49x4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115454; c=relaxed/simple; bh=1/OsxC+OQxJ+4PG/xAoVpxfCEwOMVNexaXNWHVv98Ho=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=THlYnnUPaTV4/lpE7x4GFILMwbED9wSwkcusjNSQe/g8dhaWHLNY3BMCVJJ0XY7sf8xlFxjVw+FDUaW6VUxsCo7e4daUM2WYUTlNimK9D9CGEQQx5WQ/wkptAmbqDecj94hXeFT95wR7bGXBTTkF2tQpWR032RJdBkUdS0xJb9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=YmeUyvE4; arc=none smtp.client-ip=192.19.144.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="YmeUyvE4" Received: from mail-acc-it-01.broadcom.com (mail-acc-it-01.acc.broadcom.net [10.35.36.83]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 9DEBAC0003C7; Tue, 22 Sep 2026 15:17:07 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 9DEBAC0003C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1790115427; bh=1/OsxC+OQxJ+4PG/xAoVpxfCEwOMVNexaXNWHVv98Ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmeUyvE4Aft2VKCDa98DcRk3pPka0jwHdYvwGY7wXyKXsfO78cKs7K14oWKoFiw+l rbYqeK9An1u3Aq3xvxzHf+ZilF9P1E9k2r4+ji0x8ZnLVstwZ30IKbNrVWpQmgnmBp hfxylmgkYhh5nbsAt+a22hwy8O9c45sZr2e+w6ic= Received: from stbirv-lnx-1.igp.broadcom.net (stbirv-lnx-1.igp.broadcom.net [10.67.48.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-acc-it-01.broadcom.com (Postfix) with ESMTPSA id 8E125AEA3; Tue, 22 Sep 2026 18:17:06 -0400 (EDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zak Kemble , Simon Horman , Ryo Takakura , linux-kernel@vger.kernel.org (open list), Nicolai Buchwitz Subject: [PATCH net 1/6] net: bcmasp: fix mib counters struct alignment with ethtool stats Date: Tue, 22 Sep 2026 15:16:25 -0700 Message-Id: <20260922221630.3864427-2-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260922221630.3864427-1-florian.fainelli@broadcom.com> References: <20260922221630.3864427-1-florian.fainelli@broadcom.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 Content-Type: text/plain; charset="utf-8" When EDPKT stats were removed in commit e9f31435ee7d ("net: bcmasp: Add support for asp-v3.0"), the corresponding entries were removed from bcmasp_gstrings_stats in bcmasp_ethtool.c, but the edpkt_* fields were left at the beginning of struct bcmasp_mib_counters in bcmasp.h. Because bcmasp_update_mib_counters() and bcmasp_get_ethtool_stats() index into struct bcmasp_mib_counters sequentially based on the order of bcmasp_gstrings_stats, this 16-byte offset caused hardware statistics to be written to the wrong struct members and software counters to be read from incorrect offsets (and reading out-of-bounds at the end of the struct). Remove the obsolete edpkt_* fields from struct bcmasp_mib_counters so that it aligns with bcmasp_gstrings_stats. Fixes: e9f31435ee7d ("net: bcmasp: Add support for asp-v3.0") Assisted-by: LLM Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.h b/drivers/net/ethe= rnet/broadcom/asp2/bcmasp.h index 8c8ffaeadc79..9c9721da1662 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.h +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.h @@ -250,10 +250,6 @@ struct bcmasp_intf_stats64 { }; =20 struct bcmasp_mib_counters { - u32 edpkt_ts; - u32 edpkt_rx_pkt_cnt; - u32 edpkt_hdr_ext_cnt; - u32 edpkt_hdr_out_cnt; u32 umac_frm_cnt; u32 fb_frm_cnt; u32 fb_rx_fifo_depth; --=20 2.34.1 From nobody Thu Sep 24 14:25:57 2026 Received: from relay.smtp-ext.broadcom.com (lpdvsmtp12.broadcom.com [192.19.144.207]) (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 7C6D155C317; Tue, 22 Sep 2026 22:17:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.144.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115441; cv=none; b=LaWjXWlHdcRBBunZ6I3AmR9JVMaiBqqG9teE9PqGVfZDNC2P2EPV+DEiP5SEKykWDQJWA1hl+mA60lSxTnDa+HSQ9HikYAjsfF7bJBUClP33Gw9wbipwn6EelICRsomJGOC4cc0vBmNuX+XSq7zSDlgcyHkma2pV1mbVzleZBsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115441; c=relaxed/simple; bh=X6uhqZzRl13IiMTwrMERqP27MbFj0vKF0qTTgO945wI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KyqA7LjzykG+gKJJYFej/gw8L2nTdHPLWCQo3YYshIqEg9iEMR1dbTHY5DCbcikNfChMbBEHv31M/16+Rr7jwy5Lv774JMUAp7/+ay8lpoGqwoQgyzZ6dWSWjftto/gt+YKScy4Ga5LtvdWFWsrLs5ttlTwROrGgK5VujKm3NDA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=g8lx9M8a; arc=none smtp.client-ip=192.19.144.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="g8lx9M8a" Received: from mail-acc-it-01.broadcom.com (mail-acc-it-01.acc.broadcom.net [10.35.36.83]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id D0998C0003CB; Tue, 22 Sep 2026 15:17:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com D0998C0003CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1790115428; bh=X6uhqZzRl13IiMTwrMERqP27MbFj0vKF0qTTgO945wI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g8lx9M8amlgSH1kOSUe3cEh4woxN4kXQJCDu1fkis51gi0e2u9eZbC/QiKTu0y8Ik 5yjgcGf9OBD6X7g7RMGULCQJEDatGTD4pxKU6IdMxX+9NIboiBCypckjh1DpABKFyt xUnPwhJSha9xcw+e2XBoE0uM/YrGbMNsRRBLoIpA= Received: from stbirv-lnx-1.igp.broadcom.net (stbirv-lnx-1.igp.broadcom.net [10.67.48.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-acc-it-01.broadcom.com (Postfix) with ESMTPSA id C0C10AEA2; Tue, 22 Sep 2026 18:17:07 -0400 (EDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zak Kemble , Simon Horman , Ryo Takakura , linux-kernel@vger.kernel.org (open list), Nicolai Buchwitz Subject: [PATCH net 2/6] net: bcmasp: unmap previous DMA mappings on TX map failure Date: Tue, 22 Sep 2026 15:16:26 -0700 Message-Id: <20260922221630.3864427-3-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260922221630.3864427-1-florian.fainelli@broadcom.com> References: <20260922221630.3864427-1-florian.fainelli@broadcom.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 Content-Type: text/plain; charset="utf-8" When mapping an skb with fragments for transmission in bcmasp_xmit(), if mapping fails on fragment i > 0, the error handler calls bcmasp_clean_txcb() for previous iterations j < i. However, bcmasp_clean_txcb() only zeroes the control block fields without unmapping the DMA buffers, leaking the DMA mappings allocated for the head and earlier fragments. Call dma_unmap_single() before calling bcmasp_clean_txcb() in the error cleanup loop. Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controll= er") Assisted-by: LLM Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net= /ethernet/broadcom/asp2/bcmasp_intf.c index f2176ef3a127..9ad5a982542f 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -285,6 +285,11 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, st= ruct net_device *dev) intf->mib.tx_dma_failed++; spb_index =3D intf->tx_spb_index; for (j =3D 0; j < i; j++) { + txcb =3D &intf->tx_cbs[spb_index]; + dma_unmap_single(kdev, + dma_unmap_addr(txcb, dma_addr), + dma_unmap_len(txcb, dma_len), + DMA_TO_DEVICE); bcmasp_clean_txcb(intf, spb_index); spb_index =3D incr_ring(spb_index, DESC_RING_COUNT); --=20 2.34.1 From nobody Thu Sep 24 14:25:57 2026 Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.144.205]) (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 99F284EB872; Tue, 22 Sep 2026 22:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.144.205 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115440; cv=none; b=DNk9acVPDx/JV6U4muNcqZXVp+a5gkwdMURpJ6ISpxyliIQZkIEJrKpCyMLxnqVTbGd6regRWnWyyYNQHL02O/65zV46r0DaQl1MchgflVJPx2z3XkYEXMMF50sD4XC9CeJI4LDZ60afvtQA9Nsf7kbLCslhByDsNPH7j7TR5F0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115440; c=relaxed/simple; bh=JYvjhNDYGhs5rJldHmD9vwIambpYeVwpV62wUGcNrR8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p02qbn+VLtzXl0qhbi8EPaDlX9JDnqHAQQmehs/WD3wNtHKEKz9IKWjDd0rm1V2BCufz8hCDJj2fV/oMAshPqV+LAFxoVEyF1mxOCtBoLOzn8babevVirqpmxdLwqjex9igssCAfl9c/Lf6UNWoZBftwE/kf7pT2CCigP6MXC2M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=VQbExmpd; arc=none smtp.client-ip=192.19.144.205 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="VQbExmpd" Received: from mail-acc-it-01.broadcom.com (mail-acc-it-01.acc.broadcom.net [10.35.36.83]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 0F317C0003CA; Tue, 22 Sep 2026 15:17:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 0F317C0003CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1790115430; bh=JYvjhNDYGhs5rJldHmD9vwIambpYeVwpV62wUGcNrR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VQbExmpdavQHPS7o08QlwLPKlZSY9iyAdKycUwJIpBp6aBKvOWvn1APfiE1UOfCBF YkClfZNHB5+H1lHZxw260RyYavopH0iZBS1jZYD+ecEsXewA6dtRKph3HHi5GwKjBr Xz3GW5hO/ky+U9Qflvwue+Gp3w2Fcfyp8yCjT7/Y= Received: from stbirv-lnx-1.igp.broadcom.net (stbirv-lnx-1.igp.broadcom.net [10.67.48.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-acc-it-01.broadcom.com (Postfix) with ESMTPSA id F3816AEA3; Tue, 22 Sep 2026 18:17:08 -0400 (EDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zak Kemble , Simon Horman , Ryo Takakura , linux-kernel@vger.kernel.org (open list), Nicolai Buchwitz Subject: [PATCH net 3/6] net: bcmasp: validate minimum RX packet size in bcmasp_rx_poll() Date: Tue, 22 Sep 2026 15:16:27 -0700 Message-Id: <20260922221630.3864427-4-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260922221630.3864427-1-florian.fainelli@broadcom.com> References: <20260922221630.3864427-1-florian.fainelli@broadcom.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 Content-Type: text/plain; charset="utf-8" In bcmasp_rx_poll(), the driver removes a 2-byte alignment pad and optionally strips the ETH_FCS_LEN CRC from received packets using skb_pull(skb, 2) and skb_trim(skb, len - ETH_FCS_LEN). If the hardware reports a descriptor size smaller than the pad and CRC lengths (e.g. runt or corrupted frames), len -=3D 2 or len - ETH_FCS_LEN underflows u32 len, leading to out-of-bounds trimming and memory corruption. Check that desc->size is at least the sum of the 2-byte pad and the CRC length before proceeding to process the descriptor. Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controll= er") Assisted-by: LLM Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net= /ethernet/broadcom/asp2/bcmasp_intf.c index 9ad5a982542f..2ad8a7eac888 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -523,6 +523,12 @@ static int bcmasp_rx_poll(struct napi_struct *napi, in= t budget) DMA_FROM_DEVICE); =20 len =3D desc->size; + if (unlikely(len < 2 + (intf->crc_fwd ? ETH_FCS_LEN : 0))) { + u64_stats_update_begin(&stats->syncp); + u64_stats_inc(&stats->rx_dropped); + u64_stats_update_end(&stats->syncp); + goto next; + } =20 /* Allocate a page pool page as the SKB data area so the * kernel can recycle it efficiently after the packet is --=20 2.34.1 From nobody Thu Sep 24 14:25:57 2026 Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) (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 CE45F4F55D2; Tue, 22 Sep 2026 22:17:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.166.231 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115443; cv=none; b=gme6SW5Ot4PJ3XpcxJf0S/gi+N356bM1ej7GTCEOEAZOy2n/hTwhIhy7g5990GSf0sdRgigviuPdzvvjXlDCInotIm10XQUcU5577j019LqEDrXTPepUpuQ1WcxZzlwXwH9N/rGgDBhMSIaQl+fmB+S/C1m+JwwwaV7jqLim7yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115443; c=relaxed/simple; bh=QwkWD6B6i0RCBUFL9uRTXe85erH7mal2W8MPMBGyJOc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TY9DGGyVqR+mCmCG9r9YR0SKczmmvgQVMg2SNynIVCpzd03lvK6/v39au+4nixulwggGFlSFysk5JDCaZch/Kab07cpDJnuHVrkMzo51fFKm2xFhmTqLzEAxd/35Goof4vXrnVTb+v4dMJLd7MMYyA3G6cPfT8oYZ3hP8HKIais= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=UwqI9GKr; arc=none smtp.client-ip=192.19.166.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="UwqI9GKr" Received: from mail-acc-it-01.broadcom.com (mail-acc-it-01.acc.broadcom.net [10.35.36.83]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 7757CC0000DF; Tue, 22 Sep 2026 15:17:11 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 7757CC0000DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1790115431; bh=QwkWD6B6i0RCBUFL9uRTXe85erH7mal2W8MPMBGyJOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UwqI9GKryVo0fEL886PQVTC1/jve2AdTeVpkQa0Jj58spQRzIrAVNWIHZRA7vVlsh nz8TIYd1Kzq4jIwv0UKcGMAaT/f9LeuoH4T+sX23nAPD7KAw+drH1McT/ytFIwW1tL fcLSOeWugZ2fzB9NMG7lZ9HyT8iJzpJ9ZLIRHYVo= Received: from stbirv-lnx-1.igp.broadcom.net (stbirv-lnx-1.igp.broadcom.net [10.67.48.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-acc-it-01.broadcom.com (Postfix) with ESMTPSA id 320FEAEA2; Tue, 22 Sep 2026 18:17:10 -0400 (EDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zak Kemble , Simon Horman , Ryo Takakura , linux-kernel@vger.kernel.org (open list), Nicolai Buchwitz Subject: [PATCH net 4/6] net: bcmasp: fix OF node reference leak for phy_dn Date: Tue, 22 Sep 2026 15:16:28 -0700 Message-Id: <20260922221630.3864427-5-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260922221630.3864427-1-florian.fainelli@broadcom.com> References: <20260922221630.3864427-1-florian.fainelli@broadcom.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 Content-Type: text/plain; charset="utf-8" In bcmasp_interface_create(), intf->phy_dn is obtained via of_parse_phandle() or assigned ndev_dn. of_parse_phandle() returns a node reference with its refcount incremented, but of_node_put() was never called on intf->phy_dn in bcmasp_interface_destroy() or the error unwind path in bcmasp_interface_create(). Acquire a reference on ndev_dn for the fixed-link case as well so that intf->phy_dn consistently holds a reference, and release it with of_node_put() on teardown and error. Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controll= er") Assisted-by: LLM Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net= /ethernet/broadcom/asp2/bcmasp_intf.c index 2ad8a7eac888..7a63a592f158 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -1298,7 +1298,7 @@ struct bcmasp_intf *bcmasp_interface_create(struct bc= masp_priv *priv, ndev_dn->name); goto err_free_netdev; } - intf->phy_dn =3D ndev_dn; + intf->phy_dn =3D of_node_get(ndev_dn); } =20 /* Map resource */ @@ -1338,6 +1338,7 @@ struct bcmasp_intf *bcmasp_interface_create(struct bc= masp_priv *priv, err_deregister_fixed_link: if (of_phy_is_fixed_link(ndev_dn)) of_phy_deregister_fixed_link(ndev_dn); + of_node_put(intf->phy_dn); err_free_netdev: free_netdev(ndev); err: @@ -1350,6 +1351,7 @@ void bcmasp_interface_destroy(struct bcmasp_intf *int= f) unregister_netdev(intf->ndev); if (of_phy_is_fixed_link(intf->ndev_dn)) of_phy_deregister_fixed_link(intf->ndev_dn); + of_node_put(intf->phy_dn); free_netdev(intf->ndev); } =20 --=20 2.34.1 From nobody Thu Sep 24 14:25:57 2026 Received: from relay.smtp-ext.broadcom.com (lpdvsmtp12.broadcom.com [192.19.144.207]) (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 96D4F4D9F7E; Tue, 22 Sep 2026 22:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.144.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115444; cv=none; b=PENhIQGShhcQxDn9N0a4I6nmp9pLf4RWW43AzDhxwOsRBc3FF85gUJSicD+02/MM3r76NC21zJa4B/izqt6O6VmT36v2K4Ew0EOOqBeiyQHMcE3t4tX4Wy2dgqqzOueVD4pcCO7KgdZO5OkAjlnH4yQ+GBWH07/eBUDtZzqAQzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115444; c=relaxed/simple; bh=DEd0waVIprXhh5yorRxRzU10ExFfSwXWNXxHuHIukcw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Qk1znXu86wYOohmBLQUuPsUMyYur1/2WnIkLXDDWkyxCB6mvleWCJvJSCfcHOQ7bktVEc4hAia2yTg4Auh6FRYQCZY/UMlpNehRO9Z4AkEq192YxXuF/yiz4Il4AMAV8e5xN7rSCxGV1K63HiA9ANwQH+ET+MXJX0oQJt5WFTVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=eiF+iDAn; arc=none smtp.client-ip=192.19.144.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="eiF+iDAn" Received: from mail-acc-it-01.broadcom.com (mail-acc-it-01.acc.broadcom.net [10.35.36.83]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 763D8C0003CC; Tue, 22 Sep 2026 15:17:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 763D8C0003CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1790115432; bh=DEd0waVIprXhh5yorRxRzU10ExFfSwXWNXxHuHIukcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eiF+iDAnSiyVA3V28NVeJKQxOG+1QzYqiDU+Tefy/wSOc+eNoGC1l/+epAkUPhKk2 weMIxwiAi+majb/brPxyN17g7/JmL/WDbfB6XUx8p/+iUPlnD9qND/xhk8AolJXDKo NnBIKR6a4GBrbSQhWORnA+Ruis/oGEPRnDa8hnpI= Received: from stbirv-lnx-1.igp.broadcom.net (stbirv-lnx-1.igp.broadcom.net [10.67.48.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-acc-it-01.broadcom.com (Postfix) with ESMTPSA id 659C7AEA3; Tue, 22 Sep 2026 18:17:11 -0400 (EDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zak Kemble , Simon Horman , Ryo Takakura , linux-kernel@vger.kernel.org (open list), Nicolai Buchwitz Subject: [PATCH net 5/6] net: bcmasp: account for offload header in TX short packet padding Date: Tue, 22 Sep 2026 15:16:29 -0700 Message-Id: <20260922221630.3864427-6-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260922221630.3864427-1-florian.fainelli@broadcom.com> References: <20260922221630.3864427-1-florian.fainelli@broadcom.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 Content-Type: text/plain; charset="utf-8" When hardware checksum offload is enabled for an skb, bcmasp_csum_offload() prepends a struct bcmasp_pkt_offload header (20 bytes) to the skb via skb_push(). This increases skb->len and skb_headlen(skb) by sizeof(struct bcmasp_pkt_offload). Because the hardware descriptor processor strips this offload header before transmitting the packet on the wire, the wire packet length is smaller by sizeof(struct bcmasp_pkt_offload). The padding calculation did not account for this extra header, causing short frames to skip padding and be sent on the wire smaller than the minimum Ethernet frame size (ETH_ZLEN + ETH_FCS_LEN). Add sizeof(struct bcmasp_pkt_offload) to the minimum padding threshold when hardware checksum offload is enabled. Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controll= er") Assisted-by: LLM Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net= /ethernet/broadcom/asp2/bcmasp_intf.c index 7a63a592f158..3370cbf1b395 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -236,7 +236,7 @@ static struct sk_buff *bcmasp_csum_offload(struct net_d= evice *dev, static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) { struct bcmasp_intf *intf =3D netdev_priv(dev); - unsigned int total_bytes, size; + unsigned int total_bytes, size, min_size; int spb_index, nr_frags, i, j; struct bcmasp_tx_cb *txcb; dma_addr_t mapping, valid; @@ -267,8 +267,12 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, st= ruct net_device *dev) for (i =3D 0; i <=3D nr_frags; i++) { if (!i) { size =3D skb_headlen(skb); - if (!nr_frags && size < (ETH_ZLEN + ETH_FCS_LEN)) { - if (skb_put_padto(skb, ETH_ZLEN + ETH_FCS_LEN)) + min_size =3D ETH_ZLEN + ETH_FCS_LEN; + if (csum_hw) + min_size +=3D sizeof(struct bcmasp_pkt_offload); + + if (!nr_frags && size < min_size) { + if (skb_put_padto(skb, min_size)) return NETDEV_TX_OK; size =3D skb->len; } --=20 2.34.1 From nobody Thu Sep 24 14:25:57 2026 Received: from relay.smtp-ext.broadcom.com (lpdvsmtp09.broadcom.com [192.19.166.228]) (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 EFB3D550DB4; Tue, 22 Sep 2026 22:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.166.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115453; cv=none; b=e4zmGudS8w6WNYHKYfMC1Ig9Jc8l0D4xqZwfXBGC0BhOSLDVKhBE/AvKpNMv1dkogS13fTPtdxmmHTJpDvrb3Utq47jr83NntnAWxhRpDiMbXGWu0EglcRUJ9GduA8NL0c/6xl0CIrna7/dgIXYoOiC54wM8kwljkrjLCzsaMCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790115453; c=relaxed/simple; bh=YKYgoSMK2Y5Za3PKFIrRm4dXg/IPXSdfRXPgzujtM0A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Erd1lLTNUPdhp1a333ZMCbRNC4dJLVh5CEa4UrBSpFE1fbNF88AaHFm50+Za30KM6uDYrE3AP4+sQpfqBqrMvAI5fLaR57KpdDfVwd7OBHhw3pslX6K9Hk3rOVznxEbCfYn7udd4/qc9MvbM5HKKUCgV3ifZFl/Vgcb9FTK/BwE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=sTjKuiF3; arc=none smtp.client-ip=192.19.166.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="sTjKuiF3" Received: from mail-acc-it-01.broadcom.com (mail-acc-it-01.acc.broadcom.net [10.35.36.83]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id EA9E3C0000EB; Tue, 22 Sep 2026 15:17:13 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com EA9E3C0000EB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1790115434; bh=YKYgoSMK2Y5Za3PKFIrRm4dXg/IPXSdfRXPgzujtM0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTjKuiF31FITQCnzb3qAS5Wph5dOkYIyk1beKTPgBHQgz0hNCMABh93jn2bn1t4Iw E9U5zMDedS7/2BObaKnkZmLPfwbEkMjrxz47omrdKx1AHovLYHGJ3StqR7WVAAjvxi KwEtVY/p9NE5dyrE5eSWxHuyl+a30cU53u9+aYHQ= Received: from stbirv-lnx-1.igp.broadcom.net (stbirv-lnx-1.igp.broadcom.net [10.67.48.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-acc-it-01.broadcom.com (Postfix) with ESMTPSA id 98E39AEA2; Tue, 22 Sep 2026 18:17:12 -0400 (EDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Justin Chen , Doug Berger , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zak Kemble , Simon Horman , Ryo Takakura , linux-kernel@vger.kernel.org (open list), Nicolai Buchwitz Subject: [PATCH net 6/6] net: bcmasp: fix network filter lookup and wake filter pair allocation Date: Tue, 22 Sep 2026 15:16:30 -0700 Message-Id: <20260922221630.3864427-7-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260922221630.3864427-1-florian.fainelli@broadcom.com> References: <20260922221630.3864427-1-florian.fainelli@broadcom.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 Content-Type: text/plain; charset="utf-8" Several issues exist in bcmasp_netfilt_get_init(): 1. When looking up an existing filter (!init) with a specified location (loc !=3D RX_CLS_LOC_ANY), if the filter at loc was not claimed, the loop continued searching higher indices and could return an arbitrary unrelated filter belonging to the port. This caused flow get or delete operations on an empty rule location to return or delete an unintended filter. 2. When allocating an unpositioned wake filter (wake_filter =3D=3D true and loc =3D=3D RX_CLS_LOC_ANY), if an even index was claimed or its adjacent odd index was claimed, the check fell through to the non-wake branch "else if (!priv->net_filters[i].claimed)", picking an odd index and subsequently claiming the next filter across filter pair boundaries. 3. When allocating a positioned wake filter at loc, only loc was checked for being busy, but not loc + 1, which could overwrite an existing filter at loc + 1. Fix these by checking only the requested location on lookup, properly restricting wake filter pair searches to even boundaries where both entries are free, checking loc + 1 for positioned wake filters, and preventing out-of-bounds release. Fixes: c5d511c49587 ("net: bcmasp: Add support for wake on net filters") Assisted-by: LLM Co-developed-by: Justin Chen Signed-off-by: Justin Chen Co-developed-by: Florian Fainelli Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 127 ++++++++++++-------- 1 file changed, 78 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethe= rnet/broadcom/asp2/bcmasp.c index 972474893a6b..bbd152bc3a8a 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c @@ -511,6 +511,13 @@ static int bcmasp_netfilt_wr_to_hw(struct bcmasp_priv = *priv, return 0; } =20 +static inline bool bcmasp_netfilt_is_companion(struct bcmasp_priv *priv, i= nt i) +{ + return i > 0 && (i % 2) && + priv->net_filters[i].wake_filter && + priv->net_filters[i - 1].wake_filter; +} + void bcmasp_netfilt_suspend(struct bcmasp_intf *intf) { struct bcmasp_priv *priv =3D intf->parent; @@ -524,9 +531,7 @@ void bcmasp_netfilt_suspend(struct bcmasp_intf *intf) priv->net_filters[i].port !=3D intf->port) continue; =20 - if (i > 0 && (i % 2) && - priv->net_filters[i].wake_filter && - priv->net_filters[i - 1].wake_filter) + if (bcmasp_netfilt_is_companion(priv, i)) continue; =20 ret =3D bcmasp_netfilt_wr_to_hw(priv, &priv->net_filters[i]); @@ -556,9 +561,7 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *i= ntf, u32 *rule_locs, priv->net_filters[i].port !=3D intf->port) continue; =20 - if (i > 0 && (i % 2) && - priv->net_filters[i].wake_filter && - priv->net_filters[i - 1].wake_filter) + if (bcmasp_netfilt_is_companion(priv, i)) continue; =20 if (j =3D=3D *rule_cnt) @@ -583,9 +586,7 @@ int bcmasp_netfilt_get_active(struct bcmasp_intf *intf) continue; =20 /* Skip over a wake filter pair */ - if (i > 0 && (i % 2) && - priv->net_filters[i].wake_filter && - priv->net_filters[i - 1].wake_filter) + if (bcmasp_netfilt_is_companion(priv, i)) continue; =20 cnt++; @@ -607,6 +608,9 @@ bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf, priv->net_filters[i].port !=3D intf->port) continue; =20 + if (bcmasp_netfilt_is_companion(priv, i)) + continue; + cur =3D &priv->net_filters[i].fs; =20 if (cur->flow_type !=3D fs->flow_type || @@ -659,7 +663,7 @@ bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf, } =20 /* If no network filter found, return open filter. - * If no more open filters return NULL + * If no more open filters return error. */ struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf, u32 loc, bool wake_filter, @@ -673,41 +677,61 @@ struct bcmasp_net_filter *bcmasp_netfilt_get_init(str= uct bcmasp_intf *intf, if (loc !=3D RX_CLS_LOC_ANY && loc >=3D priv->num_net_filters) return ERR_PTR(-EINVAL); =20 - /* If the filter location is busy (already claimed) and we are initializi= ng - * the filter (insertion), return a busy error code. - */ - if (loc !=3D RX_CLS_LOC_ANY && init && priv->net_filters[loc].claimed) - return ERR_PTR(-EBUSY); - - /* We need two filters for wake-up, so we cannot use an odd filter */ - if (wake_filter && loc !=3D RX_CLS_LOC_ANY && (loc % 2)) - return ERR_PTR(-EINVAL); + if (!init) { + if (loc !=3D RX_CLS_LOC_ANY) { + if (priv->net_filters[loc].claimed && + priv->net_filters[loc].port =3D=3D intf->port && + !bcmasp_netfilt_is_companion(priv, loc)) + return &priv->net_filters[loc]; + return ERR_PTR(-ENOENT); + } =20 - /* Initialize the loop index based on the desired location or from 0 */ - i =3D loc =3D=3D RX_CLS_LOC_ANY ? 0 : loc; + for (i =3D 0; i < priv->num_net_filters; i++) { + if (bcmasp_netfilt_is_companion(priv, i)) + continue; =20 - for ( ; i < priv->num_net_filters; i++) { - /* Found matching network filter */ - if (!init && - priv->net_filters[i].claimed && - priv->net_filters[i].hw_index =3D=3D i && - priv->net_filters[i].port =3D=3D intf->port) - return &priv->net_filters[i]; + if (priv->net_filters[i].claimed && + priv->net_filters[i].port =3D=3D intf->port) + return &priv->net_filters[i]; + } =20 - /* If we don't need a new filter or new filter already found */ - if (!init || open_index >=3D 0) - continue; + return ERR_PTR(-ENOENT); + } =20 - /* Wake filter conslidates two filters to cover more bytes - * Wake filter is open if... - * 1. It is an even filter - * 2. The current and next filter is not claimed - */ - if (wake_filter && !(i % 2) && !priv->net_filters[i].claimed && - !priv->net_filters[i + 1].claimed) - open_index =3D i; - else if (!priv->net_filters[i].claimed) - open_index =3D i; + /* If the filter location is busy (already claimed) and we are initializi= ng + * the filter (insertion), return a busy error code. + */ + if (loc !=3D RX_CLS_LOC_ANY) { + if (priv->net_filters[loc].claimed) + return ERR_PTR(-EBUSY); + + /* We need two filters for wake-up, so we cannot use an odd filter */ + if (wake_filter) { + if ((loc % 2) || loc + 1 >=3D priv->num_net_filters) + return ERR_PTR(-EINVAL); + if (priv->net_filters[loc + 1].claimed) + return ERR_PTR(-EBUSY); + } + open_index =3D loc; + } else { + for (i =3D 0; i < priv->num_net_filters; i++) { + /* Wake filter consolidates two filters to cover more bytes. + * Wake filter is open if: + * 1. It is an even filter + * 2. The current and next filter is not claimed + */ + if (wake_filter) { + if (!(i % 2) && (i + 1 < priv->num_net_filters) && + !priv->net_filters[i].claimed && + !priv->net_filters[i + 1].claimed) { + open_index =3D i; + break; + } + } else if (!priv->net_filters[i].claimed) { + open_index =3D i; + break; + } + } } =20 if (open_index >=3D 0) { @@ -716,16 +740,20 @@ struct bcmasp_net_filter *bcmasp_netfilt_get_init(str= uct bcmasp_intf *intf, nfilter->port =3D intf->port; nfilter->ch =3D intf->channel + priv->tx_chan_offset; nfilter->hw_index =3D open_index; - } =20 - if (wake_filter && open_index >=3D 0) { - /* Claim next filter */ - priv->net_filters[open_index + 1].claimed =3D true; - priv->net_filters[open_index + 1].wake_filter =3D true; - nfilter->wake_filter =3D true; + if (wake_filter) { + /* Claim next filter */ + priv->net_filters[open_index + 1].claimed =3D true; + priv->net_filters[open_index + 1].wake_filter =3D true; + priv->net_filters[open_index + 1].hw_index =3D open_index + 1; + priv->net_filters[open_index + 1].port =3D intf->port; + priv->net_filters[open_index + 1].ch =3D intf->channel + + priv->tx_chan_offset; + nfilter->wake_filter =3D true; + } } =20 - return nfilter ? nfilter : ERR_PTR(-EINVAL); + return nfilter ? nfilter : ERR_PTR(-ENOSPC); } =20 void bcmasp_netfilt_release(struct bcmasp_intf *intf, @@ -733,7 +761,8 @@ void bcmasp_netfilt_release(struct bcmasp_intf *intf, { struct bcmasp_priv *priv =3D intf->parent; =20 - if (nfilt->wake_filter) { + if (nfilt->wake_filter && !(nfilt->hw_index % 2) && + nfilt->hw_index + 1 < priv->num_net_filters) { memset(&priv->net_filters[nfilt->hw_index + 1], 0, sizeof(struct bcmasp_net_filter)); } --=20 2.34.1