]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bonding: check return value of register_netdevice() in bond_newlink()
authorCong Wang <xiyou.wangcong@gmail.com>
Wed, 22 Jul 2020 23:31:54 +0000 (16:31 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Jul 2020 22:17:04 +0000 (15:17 -0700)
Very similar to commit 544f287b8495
("bonding: check error value of register_netdevice() immediately"),
we should immediately check the return value of register_netdevice()
before doing anything else.

Fixes: 005db31d5f5f ("bonding: set carrier off for devices created through netlink")
Reported-and-tested-by: syzbot+bbc3a11c4da63c1b74d6@syzkaller.appspotmail.com
Cc: Beniamino Galvani <bgalvani@redhat.com>
Cc: Taehee Yoo <ap420073@gmail.com>
Cc: Jay Vosburgh <j.vosburgh@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_netlink.c

index b43b51646b11a6b7b9a8284cbb48d3d456cfdd78..f0f9138e967f3a1f4be094641c10013b2dde55b0 100644 (file)
@@ -456,11 +456,10 @@ static int bond_newlink(struct net *src_net, struct net_device *bond_dev,
                return err;
 
        err = register_netdevice(bond_dev);
-
-       netif_carrier_off(bond_dev);
        if (!err) {
                struct bonding *bond = netdev_priv(bond_dev);
 
+               netif_carrier_off(bond_dev);
                bond_work_init_all(bond);
        }