Skip to contentSkip to conversation

switchdev: change BUG_ON to WARN for attr set failure case

PATCH Applied [email protected] 2 participants 3 messages Jun 11, 2015 – Jun 17, 2015

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

PATCH 1/1 switchdev: change BUG_ON to WARN for attr set failure case

From: Scott Feldman <[email protected]>

This particular BUG_ON condition was checking for attr set err in the COMMIT phase, which isn't expected (it's a driver bug if PREPARE phase is OK but COMMIT fails). But BUG_ON() is too strong for this case, so change to WARN(). BUG_ON() would be warranted if the system was corrupted beyond repair, but this is not the case here.

---
 net/switchdev/switchdev.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/switchdev/switchdev.c +2 -1
index 658bc3a..a5d0f8e 100644
@@ -184,7 +184,8 @@ int switchdev_port_attr_set(struct net_device *dev, struct switchdev_attr *attr)
 
 	attr->trans = SWITCHDEV_TRANS_COMMIT;
 	err = __switchdev_port_attr_set(dev, attr);
-	BUG_ON(err);
+	WARN(err, "%s: Commit of attribute (id=%d) failed.\n",
+	     dev->name, attr->id);
 
 	return err;
 }
Signature · 1 line
1.7.10.4
maintainer Applied
#1 lore raw

From: [email protected]
Date: Thu, 11 Jun 2015 11:20:42 -0700

Quoted 9 lines

From: Scott Feldman <[email protected]>

This particular BUG_ON condition was checking for attr set err in the COMMIT phase, which isn't expected (it's a driver bug if PREPARE phase is OK but COMMIT fails). But BUG_ON() is too strong for this case, so change to WARN(). BUG_ON() would be warranted if the system was corrupted beyond repair, but this is not the case here.

Applied, thanks Scott.

#2 lore raw
Quoted 11 lines · David Miller

From: [email protected]
Date: Thu, 11 Jun 2015 11:20:42 -0700

Quoted 8 lines

From: Scott Feldman <[email protected]>

This particular BUG_ON condition was checking for attr set err in the COMMIT phase, which isn't expected (it's a driver bug if PREPARE phase is OK but COMMIT fails). But BUG_ON() is too strong for this case, so change to WARN(). BUG_ON() would be warranted if the system was corrupted beyond repair, but this is not the case here.

Quoted 3 lines
Quoted 1 line

Applied, thanks Scott.

I think this one slipped thru the cracks. I'm not seeing it in net-next.