From nobody Tue Apr 7 14:05:57 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A2EA3D3485; Wed, 25 Feb 2026 14:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772029477; cv=none; b=aA1Cm3s4QVkGiGbHUMyg+75DHvIcvubgt7+9pXvoB3M4JYLPSVBVxH1jwxx6DL8RbcYEubO22gGgZKTc88ThVisP77hpZbATlr6SPqiki758W1oZkMCeV3FK+Uz6G/f987vDxqyKpSlFh3+lU8s+qv7DGcXsfr95O/zWy1H7Ta8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772029477; c=relaxed/simple; bh=/j+KKokPmqND21UBiNjdIW9ARxpHY/OtdFIFrZnogdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V4utqL3s6hTtHgQ9T7yCPAcH1m7nvdMwk6IB0weQu1yznPumfJSBxkd1IL0B32DWzqsB4CAzaMYIeqLTtw+VaJfWHPA5t9SF+opklAWMHuSZlOJ3tKAMxRRnEWlXk0Z6kfOGHL4riEmTfQtgeUj18Onb7kSz+B0oHqsf/wg6iXk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: onbCMC7XSyWtP4f3YSZ8Uw== X-CSE-MsgGUID: fx56hqT+ToOjKXfaFqOYPQ== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 25 Feb 2026 23:24:28 +0900 Received: from vm01.adwin.renesas.com (unknown [10.226.92.192]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 661CC4017D8D; Wed, 25 Feb 2026 23:24:22 +0900 (JST) From: Ovidiu Panait To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux@armlinux.org.uk, rmk+kernel@armlinux.org.uk, maxime.chevallier@bootlin.com, boon.khai.ng@altera.com, rohan.g.thomas@altera.com, vladimir.oltean@nxp.com, hayashi.kunihiko@socionext.com, boon.leong.ong@intel.com, kim.tatt.chuah@intel.com Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 1/5] net: stmmac: Fix error handling in VLAN add and delete paths Date: Wed, 25 Feb 2026 14:24:10 +0000 Message-ID: <20260225142414.130144-2-ovidiu.panait.rb@renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260225142414.130144-1-ovidiu.panait.rb@renesas.com> References: <20260225142414.130144-1-ovidiu.panait.rb@renesas.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" stmmac_vlan_rx_add_vid() updates active_vlans and the VLAN hash register before writing the HW filter entry. If the filter write fails, it leaves a stale VID in active_vlans and the hash register. stmmac_vlan_rx_kill_vid() has the reverse problem: it clears active_vlans before removing the HW filter. On failure, the VID is gone from active_vlans but still present in the HW filter table. To fix this, reorder the operations to update the hash table first, then attempt the HW filter operation. If the HW filter fails, roll back both the active_vlans bitmap and the hash table by calling stmmac_vlan_update() again. Fixes: ed64639bc1e0 ("net: stmmac: Add support for VLAN Rx filtering") Signed-off-by: Ovidiu Panait --- v2 changes: none. .../net/ethernet/stmicro/stmmac/stmmac_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 82375d34ad57..f2f120ddba46 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6798,9 +6798,13 @@ static int stmmac_vlan_rx_add_vid(struct net_device = *ndev, __be16 proto, u16 vid =20 if (priv->hw->num_vlan) { ret =3D stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); - if (ret) + if (ret) { + clear_bit(vid, priv->active_vlans); + stmmac_vlan_update(priv, is_double); goto err_pm_put; + } } + err_pm_put: pm_runtime_put(priv->device); =20 @@ -6824,15 +6828,21 @@ static int stmmac_vlan_rx_kill_vid(struct net_devic= e *ndev, __be16 proto, u16 vi is_double =3D true; =20 clear_bit(vid, priv->active_vlans); + ret =3D stmmac_vlan_update(priv, is_double); + if (ret) { + set_bit(vid, priv->active_vlans); + goto del_vlan_error; + } =20 if (priv->hw->num_vlan) { ret =3D stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); - if (ret) + if (ret) { + set_bit(vid, priv->active_vlans); + stmmac_vlan_update(priv, is_double); goto del_vlan_error; + } } =20 - ret =3D stmmac_vlan_update(priv, is_double); - del_vlan_error: pm_runtime_put(priv->device); =20 --=20 2.51.0