Sysfs files for a network device can not unconditionally take the
rtnl_lock as the bonding sysfs files do.  If someone accesses those
sysfs files while the network device is being unregistered with the
rtnl_lock held we will deadlock.
So use trylock and restart_syscall to avoid this problem.
Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
 
        /* Note:  We can't hold bond->lock here, as bond_create grabs it. */
 
-       rtnl_lock();
+       if (!rtnl_trylock())
+               return restart_syscall();
        down_write(&(bonding_rwsem));
 
        sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
        struct slave *slave;
        struct bonding *bond = to_bond(d);
 
-       rtnl_lock();
+       if (!rtnl_trylock())
+               return restart_syscall();
        read_lock(&bond->lock);
        write_lock_bh(&bond->curr_slave_lock);
 
         struct slave *new_active = NULL;
        struct bonding *bond = to_bond(d);
 
-       rtnl_lock();
+       if (!rtnl_trylock())
+               return restart_syscall();
        read_lock(&bond->lock);
        write_lock_bh(&bond->curr_slave_lock);