public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit()
@ 2026-03-05  0:53 Mark Adamenko
  2026-03-09 16:41 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Adamenko @ 2026-03-05  0:53 UTC (permalink / raw)
  To: linux-staging; +Cc: gregkh, linux-kernel, 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.

Signed-off-by: Mark Adamenko <marusik.adamenko@gmail.com>
---
 drivers/staging/octeon/ethernet-tx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index f5bbedac6a65..f34d82a433e3 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -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) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit()
  2026-03-05  0:53 [PATCH] staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit() Mark Adamenko
@ 2026-03-09 16:41 ` Greg KH
  2026-03-09 20:12   ` David Laight
  2026-03-10  0:37   ` Mark Adamenko
  0 siblings, 2 replies; 4+ messages in thread
From: Greg KH @ 2026-03-09 16:41 UTC (permalink / raw)
  To: Mark Adamenko; +Cc: linux-staging, linux-kernel

On Wed, Mar 04, 2026 at 04:53:16PM -0800, Mark Adamenko wrote:
> 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.
> 
> Signed-off-by: Mark Adamenko <marusik.adamenko@gmail.com>
> ---
>  drivers/staging/octeon/ethernet-tx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
> index f5bbedac6a65..f34d82a433e3 100644
> --- a/drivers/staging/octeon/ethernet-tx.c
> +++ b/drivers/staging/octeon/ethernet-tx.c
> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit()
  2026-03-09 16:41 ` Greg KH
@ 2026-03-09 20:12   ` David Laight
  2026-03-10  0:37   ` Mark Adamenko
  1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2026-03-09 20:12 UTC (permalink / raw)
  To: Greg KH; +Cc: Mark Adamenko, linux-staging, linux-kernel

On Mon, 9 Mar 2026 17:41:14 +0100
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Wed, Mar 04, 2026 at 04:53:16PM -0800, Mark Adamenko wrote:
> > 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.
> > 
> > Signed-off-by: Mark Adamenko <marusik.adamenko@gmail.com>
> > ---
> >  drivers/staging/octeon/ethernet-tx.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
> > index f5bbedac6a65..f34d82a433e3 100644
> > --- a/drivers/staging/octeon/ethernet-tx.c
> > +++ b/drivers/staging/octeon/ethernet-tx.c
> > @@ -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

> 
> thanks,
> 
> greg k-h
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit()
  2026-03-09 16:41 ` Greg KH
  2026-03-09 20:12   ` David Laight
@ 2026-03-10  0:37   ` Mark Adamenko
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Adamenko @ 2026-03-10  0:37 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-staging, linux-kernel

> 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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-10  0:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05  0:53 [PATCH] staging: octeon: replace BUG() with WARN_ON_ONCE() in cvn_oct_xmit() Mark Adamenko
2026-03-09 16:41 ` Greg KH
2026-03-09 20:12   ` David Laight
2026-03-10  0:37   ` Mark Adamenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox