linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Olle Lukowski <olle@lukowski.dev>
Cc: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>,
	Christian Gromm <christian.gromm@microchip.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] staging: most: i2c: replace BUG_ON() with WARN_ON_ONCE() and return error
Date: Tue, 21 Oct 2025 14:24:47 +0200	[thread overview]
Message-ID: <2025102130-siberian-rut-3a96@gregkh> (raw)
In-Reply-To: <20251021-staging-most-warn-v1-1-4cdd3745bbdc@lukowski.dev>

On Tue, Oct 21, 2025 at 03:16:27PM +0300, Olle Lukowski wrote:
> Replace BUG_ON() checks for invalid channel indices with WARN_ON_ONCE()
> and return -EINVAL to avoid crashing the kernel unnecessarily.
> 
> Signed-off-by: Olle Lukowski <olle@lukowski.dev>
> ---
>  drivers/staging/most/i2c/i2c.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/most/i2c/i2c.c b/drivers/staging/most/i2c/i2c.c
> index 184b2dd11..b9267c3fc 100644
> --- a/drivers/staging/most/i2c/i2c.c
> +++ b/drivers/staging/most/i2c/i2c.c
> @@ -71,7 +71,8 @@ static int configure_channel(struct most_interface *most_iface,
>  	struct hdm_i2c *dev = to_hdm(most_iface);
>  	unsigned int delay, pr;
>  
> -	BUG_ON(ch_idx < 0 || ch_idx >= NUM_CHANNELS);
> +	if (WARN_ON_ONCE(ch_idx < 0 || ch_idx >= NUM_CHANNELS))
> +		return -EINVAL;

If this is something that can actually ever happen, this change really
doesn't do anything well.  Many systems (i.e. the HUGE majority of Linux
instances in the world, billions) are running with panic-on-warn set, so
that means this will still reboot the box.

So please, just properly handle the issue and return an error and do not
panic the system.

Same for the other patches in this series.

thanks,

greg k-h

  reply	other threads:[~2025-10-21 12:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-21 12:16 [PATCH 0/3] staging: most: replace BUG_ON() with WARN_ON_ONCE() Olle Lukowski
2025-10-21 12:16 ` [PATCH 1/3] staging: most: i2c: replace BUG_ON() with WARN_ON_ONCE() and return error Olle Lukowski
2025-10-21 12:24   ` Greg Kroah-Hartman [this message]
2025-10-21 12:16 ` [PATCH 2/3] staging: most: dim2: replace BUG_ON() with WARN_ON_ONCE() and proper error returns Olle Lukowski
2025-10-21 12:16 ` [PATCH 3/3] staging: most: video: replace BUG_ON() with WARN_ON_ONCE() Olle Lukowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2025102130-siberian-rut-3a96@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=christian.gromm@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=olle@lukowski.dev \
    --cc=parthiban.veerasooran@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).