Skip to contentSkip to conversation

bridge:Fix incorrect variable assignment on error path in br_sysfs_addbr

PATCH Applied Bastien Philbert 2 participants 3 messages Apr 3, 2016 – Apr 4, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bridge:Fix incorrect variable assignment on error path in br_sysfs_addbr

This fixes the incorrect variable assignment on error path in br_sysfs_addbr for when the call to kobject_create_and_add fails to assign the value of -EINVAL to the returned variable of err rather then incorrectly return zero making callers think this function has succeededed due to the previous assignment being assigned zero when assigning it the successful return value of the call to sysfs_create_group which is zero.

---
 net/bridge/br_sysfs_br.c | 1 +
 1 file changed, 1 insertion(+)
net/bridge/br_sysfs_br.c +1 -0
index 6b80914..f4d40ed 100644
@@ -870,6 +870,7 @@ int br_sysfs_addbr(struct net_device *dev)
 
 	br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj);
 	if (!br->ifobj) {
+		err = -EINVAL;
 		pr_info("%s: can't add kobject (directory) %s/%s\n",
 			__func__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR);
 		goto out3;
Signature · 1 line
2.5.0
maintainer Applied
#1 lore raw

From: Bastien Philbert <[email protected]>
Date: Sun, 3 Apr 2016 19:04:26 -0400

Quoted 9 lines

This fixes the incorrect variable assignment on error path in br_sysfs_addbr for when the call to kobject_create_and_add fails to assign the value of -EINVAL to the returned variable of err rather then incorrectly return zero making callers think this function has succeededed due to the previous assignment being assigned zero when assigning it the successful return value of the call to sysfs_create_group which is zero.

Applied, but please put a space after the subsystem prefix and the colon character in your subject lines in the future.

Doesn't that really look odd to you, the way you did it? "net:Fix"?

Doesn't it look more natural, and consistent with what all other patch submitters do, if it's "net: Fix"?

Thanks.

#2 lore raw
Quoted 16 lines · David Miller

From: Bastien Philbert <[email protected]>
Date: Sun, 3 Apr 2016 19:04:26 -0400

Quoted 9 lines

This fixes the incorrect variable assignment on error path in br_sysfs_addbr for when the call to kobject_create_and_add fails to assign the value of -EINVAL to the returned variable of err rather then incorrectly return zero making callers think this function has succeededed due to the previous assignment being assigned zero when assigning it the successful return value of the call to sysfs_create_group which is zero.

Applied, but please put a space after the subsystem prefix and the colon character in your subject lines in the future.

Quoted 7 lines

Doesn't that really look odd to you, the way you did it? "net:Fix"?

Doesn't it look more natural, and consistent with what all other patch submitters do, if it's "net: Fix"?

Thanks.

Done, sorry about that :(. Will remember for future patches. Bastien