]> git.baikalelectronics.ru Git - kernel.git/commit
bonding: fix netdev event NULL pointer dereference
authornikolay@redhat.com <nikolay@redhat.com>
Thu, 11 Apr 2013 09:18:55 +0000 (09:18 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Apr 2013 20:01:47 +0000 (16:01 -0400)
commit99bf9f29f8c5936422c09cb8eb7c1c8e15e02d65
tree02a81e2e58e4fda541f1d3c64cee787bdcdf757f
parentbbebb126a8ba0871bce048aef7ee690105367200
bonding: fix netdev event NULL pointer dereference

In commit 48e59719e88cf07862aa3cdffbc5b7d440d4539e ("bonding: remove
usage of dev->master") a bug was introduced which causes a NULL pointer
dereference. If a bond device is in mode 6 (ALB) and a slave is added
it will dereference a NULL pointer in bond_slave_netdev_event().
This is because in bond_enslave we have bond_alb_init_slave() which
changes the MAC address of the slave and causes a NETDEV_CHANGEADDR.
Then we have in bond_slave_netdev_event():
        struct slave *slave = bond_slave_get_rtnl(slave_dev);
        struct bonding *bond = slave->bond;
bond_slave_get_rtnl() dereferences slave_dev->rx_handler_data which at
that time is NULL since netdev_rx_handler_register() is called later.

This is fixed by checking if slave is NULL before dereferencing it.

v2: Comment style changed.

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c