Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

macvlan: Fix memleak on device removal/crash on module removal

As noticed by Ben Greear, macvlan crashes the kernel when unloading the
module. The reason is that it tries to clean up the macvlan_port pointer
on the macvlan device itself instead of the underlying device. A non-NULL
pointer is taken as indication that the macvlan_handle_frame_hook is
valid, when receiving the next packet on the underlying device it tries
to call the NULL hook and crashes.

Clean up the macvlan_port on the correct device to fix this.

Signed-off-by; Patrick McHardy <kaber@trash.net>
Tested-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Patrick McHardy and committed by
David S. Miller
73120964 c67fa027

+1 -1
+1 -1
drivers/net/macvlan.c
··· 450 450 unregister_netdevice(dev); 451 451 452 452 if (list_empty(&port->vlans)) 453 - macvlan_port_destroy(dev); 453 + macvlan_port_destroy(port->dev); 454 454 } 455 455 456 456 static struct rtnl_link_ops macvlan_link_ops __read_mostly = {