Skip to contentSkip to conversation

staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit()

PATCH In review Mark Adamenko 3 participants 4 messages Mar 5 – Mar 10 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit()

All three values of queue_type are handled in the switch case, making the default case unreachable. Replace BUG() with WARN_ON_ONCE() to avoid an unnecessary kernel crash if reached.

---
 drivers/staging/octeon/ethernet-tx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/octeon/ethernet-tx.c +2 -1
index f5bbedac6a65..f34d82a433e3 100644
@@ -450,7 +450,8 @@ netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
 		__skb_queue_tail(&priv->tx_free_list[qos], skb);
 		break;
 	default:
-		BUG();
+		WARN_ON_ONCE(1);
+		break;
 	}
 
 	while (skb_to_free > 0) {
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 14 lines · Mark Adamenko

All three values of queue_type are handled in the switch case, making the default case unreachable. Replace BUG() with WARN_ON_ONCE() to avoid an unnecessary kernel crash if reached.

---
 drivers/staging/octeon/ethernet-tx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/octeon/ethernet-tx.c +0 -0
index f5bbedac6a65..f34d82a433e3 100644

drivers/staging/octeon/ethernet-tx.c netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) · line 454

Quoted 6 lines
drivers/staging/octeon/ethernet-tx.c +2 -1
@@ -450,7 +450,8 @@ netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
 		__skb_queue_tail(&priv->tx_free_list[qos], skb);
 		break;
 	default:
-		BUG();
+		WARN_ON_ONCE(1);
+		break;

If this is impossible to ever hit, then nothing changed here, right? So why is this even needed?

thanks,

greg k-h

#2 lore raw
Quoted 10 lines · On Mon, 9 Mar 2026 17:41:14 +0100 Greg KH <[email protected]> wrote:
Quoted 9 lines · Mark Adamenko

All three values of queue_type are handled in the switch case, making the default case unreachable. Replace BUG() with WARN_ON_ONCE() to avoid an unnecessary kernel crash if reached.

---
 drivers/staging/octeon/ethernet-tx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines

drivers/staging/octeon/ethernet-tx.c netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) · line 454

Quoted 11 lines
drivers/staging/octeon/ethernet-tx.c +2 -1
index f5bbedac6a65..f34d82a433e3 100644
@@ -450,7 +450,8 @@ netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
 		__skb_queue_tail(&priv->tx_free_list[qos], skb);
 		break;
 	default:
-		BUG();
+		WARN_ON_ONCE(1);
+		break;  

If this is impossible to ever hit, then nothing changed here, right? So why is this even needed?

Jeepers, that code is horrid....
But it is trivially impossible to get there.
The compiler might even optimise it away!

David

Quoted 5 lines

thanks,

greg k-h

#3 lore raw
In reply to Greg KH
Quoted 2 lines

If this is impossible to ever hit, then nothing changed here, right? So why is this even needed?

You're right. Would removing the default case entirely be preferred?