netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: felix:  Add NULL check for outer_tagging_rule()
@ 2025-02-13  4:07 Wentao Liang
  2025-02-13  5:59 ` Michal Swiatkowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wentao Liang @ 2025-02-13  4:07 UTC (permalink / raw)
  To: vladimir.oltean, claudiu.manoil, alexandre.belloni,
	UNGLinuxDriver, andrew, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Wentao Liang, stable

In felix_update_tag_8021q_rx_rules(), the return value of
ocelot_vcap_block_find_filter_by_id() is not checked, which could
lead to a NULL pointer dereference if the filter is not found.

Add the necessary check and use `continue` to skip the current CPU
port if the filter is not found, ensuring that all CPU ports are
processed.

Fixes: f1288fd7293b ("net: dsa: felix: fix VLAN tag loss on CPU reception with ocelot-8021q")
Cc: stable@vger.kernel.org # 6.11+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/dsa/ocelot/felix.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 3aa9c997018a..10ad43108b88 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -348,6 +348,8 @@ static int felix_update_tag_8021q_rx_rules(struct dsa_switch *ds, int port,
 
 		outer_tagging_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_es0,
 									 cookie, false);
+		if (!outer_tagging_rule)
+			continue;
 
 		felix_update_tag_8021q_rx_rule(outer_tagging_rule, vlan_filtering);
 
-- 
2.42.0.windows.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-13 22:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13  4:07 [PATCH] net: dsa: felix: Add NULL check for outer_tagging_rule() Wentao Liang
2025-02-13  5:59 ` Michal Swiatkowski
2025-02-13 13:08 ` Andrew Lunn
2025-02-13 22:21 ` Vladimir Oltean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).