]> git.baikalelectronics.ru Git - kernel.git/commit
net: mscc: ocelot: fix use-after-free in ocelot_vlan_del()
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 14 Feb 2022 23:42:00 +0000 (01:42 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 15 Feb 2022 14:38:20 +0000 (14:38 +0000)
commit854dca553cde1b679098d435a180b44d3724e29b
tree28ac2d8908ced43c0fe84c3767f7c1746a63c7c1
parent2cd5a0c389a5c495e6d9594b95b38c8d606f333c
net: mscc: ocelot: fix use-after-free in ocelot_vlan_del()

ocelot_vlan_member_del() will free the struct ocelot_bridge_vlan, so if
this is the same as the port's pvid_vlan which we access afterwards,
what we're accessing is freed memory.

Fix the bug by determining whether to clear ocelot_port->pvid_vlan prior
to calling ocelot_vlan_member_del().

Fixes: 15098771f48d ("net: mscc: ocelot: track the port pvid using a pointer")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mscc/ocelot.c