提交 73120964 编写于 作者: P Patrick McHardy 提交者: David S. Miller

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: NBen Greear <greearb@candelatech.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c67fa027
...@@ -450,7 +450,7 @@ static void macvlan_dellink(struct net_device *dev) ...@@ -450,7 +450,7 @@ static void macvlan_dellink(struct net_device *dev)
unregister_netdevice(dev); unregister_netdevice(dev);
if (list_empty(&port->vlans)) if (list_empty(&port->vlans))
macvlan_port_destroy(dev); macvlan_port_destroy(port->dev);
} }
static struct rtnl_link_ops macvlan_link_ops __read_mostly = { static struct rtnl_link_ops macvlan_link_ops __read_mostly = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册