Skip to content
/ linux Public

Commit cc1b179

Browse files
haruki3hhhSasha Levin
authored andcommitted
net: mscc: ocelot: add missing lock protection in ocelot_port_xmit_inj()
[ Upstream commit 026f651 ] ocelot_port_xmit_inj() calls ocelot_can_inject() and ocelot_port_inject_frame() without holding the injection group lock. Both functions contain lockdep_assert_held() for the injection lock, and the correct caller felix_port_deferred_xmit() properly acquires the lock using ocelot_lock_inj_grp() before calling these functions. Add ocelot_lock_inj_grp()/ocelot_unlock_inj_grp() around the register injection path to fix the missing lock protection. The FDMA path is not affected as it uses its own locking mechanism. Fixes: c5e12ac ("net: mscc: ocelot: serialize access to the injection/extraction groups") Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20260208225602.1339325-4-n7l8m4@u.northwestern.edu Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 357a354 commit cc1b179

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/net/ethernet/mscc/ocelot_net.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,14 +597,22 @@ static netdev_tx_t ocelot_port_xmit_inj(struct sk_buff *skb,
597597
int port = priv->port.index;
598598
u32 rew_op = 0;
599599

600-
if (!ocelot_can_inject(ocelot, 0))
600+
ocelot_lock_inj_grp(ocelot, 0);
601+
602+
if (!ocelot_can_inject(ocelot, 0)) {
603+
ocelot_unlock_inj_grp(ocelot, 0);
601604
return NETDEV_TX_BUSY;
605+
}
602606

603-
if (!ocelot_xmit_timestamp(ocelot, port, skb, &rew_op))
607+
if (!ocelot_xmit_timestamp(ocelot, port, skb, &rew_op)) {
608+
ocelot_unlock_inj_grp(ocelot, 0);
604609
return NETDEV_TX_OK;
610+
}
605611

606612
ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb);
607613

614+
ocelot_unlock_inj_grp(ocelot, 0);
615+
608616
consume_skb(skb);
609617

610618
return NETDEV_TX_OK;

0 commit comments

Comments
 (0)