bonding: fix error unwind in bonding_store_bonds

Fixed an error unwind in bonding_store_bonds that didn't release
the locks it held, and consolidated unwinds into a common block at the
end of the function. Bug reported by Pavel Emelyanov <xemul@openvz.org>,
who provided a different fix.

Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by Jay Vosburgh and committed by Jeff Garzik c4ebc66a 822973ba

+8 -8
+8 -8
drivers/net/bonding/bond_sysfs.c
··· 146 146 ": Unable remove bond %s due to open references.\n", 147 147 ifname); 148 148 res = -EPERM; 149 - goto out; 149 + goto out_unlock; 150 150 } 151 151 printk(KERN_INFO DRV_NAME 152 152 ": %s is being deleted...\n", 153 153 bond->dev->name); 154 154 bond_destroy(bond); 155 - up_write(&bonding_rwsem); 156 - rtnl_unlock(); 157 - goto out; 155 + goto out_unlock; 158 156 } 159 157 160 158 printk(KERN_ERR DRV_NAME 161 159 ": unable to delete non-existent bond %s\n", ifname); 162 160 res = -ENODEV; 163 - up_write(&bonding_rwsem); 164 - rtnl_unlock(); 165 - goto out; 161 + goto out_unlock; 166 162 } 167 163 168 164 err_no_cmd: 169 165 printk(KERN_ERR DRV_NAME 170 166 ": no command found in bonding_masters. Use +ifname or -ifname.\n"); 171 - res = -EPERM; 167 + return -EPERM; 168 + 169 + out_unlock: 170 + up_write(&bonding_rwsem); 171 + rtnl_unlock(); 172 172 173 173 /* Always return either count or an error. If you return 0, you'll 174 174 * get called forever, which is bad.