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