From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9A999307AC7; Mon, 13 Apr 2026 16:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776098318; cv=none; b=iq4hkYEQ/0e1TEfd0ai1rn4LC5Gu4ocfIGbY/nKlbjxNfg1qFQ1T2OuhkqEG33zPfUUC9jQHk/sO5OPMaz+ibmZrR+8/gZYOkujGpO0NXe3jWmuMlqgcX2WsDaka95auyhvfZ+OFO5E135GHS19tWoVo57t7Zi/iAGiP/S/esT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776098318; c=relaxed/simple; bh=hV8UVu5Fwwk44YWHCj1ayAp3TApY8APT3MS+0n7Ez04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tT3MdmTXC4QpPLlMPYML7LmDHJsKBeaYNYfsJ0s9kXcp40xnrFl4KEgVV1YbjGlr8u/dab9N5KxqID14DE0m7I2IhKeVWJ5nv4ATH0GYvmOGAbJdYxFu29vLdHX+t8DhGxWMIS9R6JlfxymASoAWxbsV83AxD9Gv17BFbp2lHs4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yMG0QzUY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yMG0QzUY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E28BC2BCAF; Mon, 13 Apr 2026 16:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776098318; bh=hV8UVu5Fwwk44YWHCj1ayAp3TApY8APT3MS+0n7Ez04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yMG0QzUYWnoqOWpdfDmr0BAd0piL5XgcbdOIRD4H2lLxGKfBvYLAqV3pbHAfq1BMk QHp8nVFqPOyZkjH9JCW5Lg2CscnkGiySDWrLIlEf7e3iqKV63F5QgvPfWWjY2wHRV6 FMeoxW0UI1PopG6dMWp9ukIrBOtbjhQPe2GqhABI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Luka Gejak , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 436/570] net: hsr: fix VLAN add unwind on slave errors Date: Mon, 13 Apr 2026 17:59:27 +0200 Message-ID: <20260413155846.808326507@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luka Gejak [ Upstream commit 2e3514e63bfb0e972b1f19668547a455d0129e88 ] When vlan_vid_add() fails for a secondary slave, the error path calls vlan_vid_del() on the failing port instead of the peer slave that had already succeeded. This results in asymmetric VLAN state across the HSR pair. Fix this by switching to a centralized unwind path that removes the VID from any slave device that was already programmed. Fixes: 1a8a63a5305e ("net: hsr: Add VLAN CTAG filter support") Signed-off-by: Luka Gejak Link: https://patch.msgid.link/20260401092243.52121-3-luka.gejak@linux.dev Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/hsr/hsr_device.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 85537b245aaeb..0d7550f7498e1 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -476,8 +476,8 @@ static void hsr_change_rx_flags(struct net_device *dev, int change) static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) { - bool is_slave_a_added = false; - bool is_slave_b_added = false; + struct net_device *slave_a_dev = NULL; + struct net_device *slave_b_dev = NULL; struct hsr_port *port; struct hsr_priv *hsr; int ret = 0; @@ -493,33 +493,35 @@ static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, switch (port->type) { case HSR_PT_SLAVE_A: if (ret) { - /* clean up Slave-B */ netdev_err(dev, "add vid failed for Slave-A\n"); - if (is_slave_b_added) - vlan_vid_del(port->dev, proto, vid); - return ret; + goto unwind; } - - is_slave_a_added = true; + slave_a_dev = port->dev; break; - case HSR_PT_SLAVE_B: if (ret) { - /* clean up Slave-A */ netdev_err(dev, "add vid failed for Slave-B\n"); - if (is_slave_a_added) - vlan_vid_del(port->dev, proto, vid); - return ret; + goto unwind; } - - is_slave_b_added = true; + slave_b_dev = port->dev; break; default: + if (ret) + goto unwind; break; } } return 0; + +unwind: + if (slave_a_dev) + vlan_vid_del(slave_a_dev, proto, vid); + + if (slave_b_dev) + vlan_vid_del(slave_b_dev, proto, vid); + + return ret; } static int hsr_ndo_vlan_rx_kill_vid(struct net_device *dev, -- 2.53.0