public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Mark Adamenko <marusik.adamenko@gmail.com>
Cc: linux-staging@lists.linux.dev,
	parthiban.veerasooran@microchip.com,
	christian.gromm@microchip.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: most: dim2: replace BUG_ON() with error handling
Date: Sun, 8 Mar 2026 19:45:13 +0100	[thread overview]
Message-ID: <2026030857-lagging-emcee-95f9@gregkh> (raw)
In-Reply-To: <20260305020148.59842-1-marusik.adamenko@gmail.com>

On Wed, Mar 04, 2026 at 06:01:48PM -0800, Mark Adamenko wrote:
> Replace BUG_ON() calls with error handling to avoid unnecessary kernel
> crashes.
> 
> Signed-off-by: Mark Adamenko <marusik.adamenko@gmail.com>
> ---
>  drivers/staging/most/dim2/dim2.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
> index 8d649d920433..cec9d19e1cde 100644
> --- a/drivers/staging/most/dim2/dim2.c
> +++ b/drivers/staging/most/dim2/dim2.c
> @@ -168,8 +168,10 @@ static int try_start_dim_transfer(struct hdm_channel *hdm_ch)
>  	unsigned long flags;
>  	struct dim_ch_state st;
>  
> -	BUG_ON(!hdm_ch);
> -	BUG_ON(!hdm_ch->is_initialized);
> +	if (!hdm_ch)
> +		return -EINVAL;

Can this ever happen?  If not, why is this even checked?  (hint, I do
not think it ever can)

> +	if (!hdm_ch->is_initialized)
> +		return -EINVAL;

Same here, are you sure this can happen?  And can the caller handle an
error?  At first glance, I do not think it can.  So be careful with
this.

You can't just blindly replace BUG_ON() with tests, please verify if
they are needed, and if so, how to handle the error correctly.

thanks,

greg k-h

      reply	other threads:[~2026-03-08 18:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-05  2:01 [PATCH] staging: most: dim2: replace BUG_ON() with error handling Mark Adamenko
2026-03-08 18:45 ` Greg KH [this message]

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=2026030857-lagging-emcee-95f9@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=christian.gromm@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=marusik.adamenko@gmail.com \
    --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