staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit()
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
@@ -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
Greg KH
maintainerQuoted 14 lines · Mark Adamenko
All three values of
queue_typeare handled in the switch case, making the default case unreachable. ReplaceBUG()withWARN_ON_ONCE()to avoid an unnecessary kernel crash if reached.Signed-off-by Mark Adamenko <[email protected]>--- drivers/staging/octeon/ethernet-tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/octeon/ethernet-tx.c +0
-0
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
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_typeare handled in the switch case, making the default case unreachable. ReplaceBUG()withWARN_ON_ONCE()to avoid an unnecessary kernel crash if reached.Signed-off-by Mark Adamenko <[email protected]>--- 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@@ -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
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?