forked from mirrors/linux
		
	bonding: Fix reference count leak in bond_sysfs_slave_add.
kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object. Previous
commit "b8eb718348b8" fixed a similar problem.
Fixes: 07699f9a7c ("bonding: add sysfs /slave dir for bond slave devices.")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
			
			
This commit is contained in:
		
							parent
							
								
									2200313aa0
								
							
						
					
					
						commit
						a068aab422
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -149,8 +149,10 @@ int bond_sysfs_slave_add(struct slave *slave)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = kobject_init_and_add(&slave->kobj, &slave_ktype,
 | 
						err = kobject_init_and_add(&slave->kobj, &slave_ktype,
 | 
				
			||||||
				   &(slave->dev->dev.kobj), "bonding_slave");
 | 
									   &(slave->dev->dev.kobj), "bonding_slave");
 | 
				
			||||||
	if (err)
 | 
						if (err) {
 | 
				
			||||||
 | 
							kobject_put(&slave->kobj);
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (a = slave_attrs; *a; ++a) {
 | 
						for (a = slave_attrs; *a; ++a) {
 | 
				
			||||||
		err = sysfs_create_file(&slave->kobj, &((*a)->attr));
 | 
							err = sysfs_create_file(&slave->kobj, &((*a)->attr));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue