All of lore.kernel.org
 help / color / mirror / Atom feed
From: grondon@gmail.com
To: parthiban.veerasooran@microchip.com,
	christian.gromm@microchip.com, gregkh@linuxfoundation.org
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Gabriel Rondon <grondon@gmail.com>
Subject: [PATCH v2 1/5] staging: most: dim2: replace BUG_ON() in try_start_dim_transfer()
Date: Mon, 30 Mar 2026 19:22:51 +0100	[thread overview]
Message-ID: <20260330182255.75241-2-grondon@gmail.com> (raw)
In-Reply-To: <20260330182255.75241-1-grondon@gmail.com>

From: Gabriel Rondon <grondon@gmail.com>

Replace BUG_ON() calls with graceful error handling.

For the null/uninitialized channel checks, return -EINVAL instead of
crashing the kernel. For the zero bus_address check, release the
spinlock and return -EFAULT.

BUG_ON() is deprecated as it crashes the entire kernel on assertion
failure (see Documentation/process/deprecated.rst).

Signed-off-by: Gabriel Rondon <grondon@gmail.com>
---
 drivers/staging/most/dim2/dim2.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
index 66617e89e..48315f8cd 100644
--- a/drivers/staging/most/dim2/dim2.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -165,8 +165,8 @@ 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 || !hdm_ch->is_initialized)
+		return -EINVAL;
 
 	spin_lock_irqsave(&dim_lock, flags);
 	if (list_empty(head)) {
@@ -187,7 +187,10 @@ static int try_start_dim_transfer(struct hdm_channel *hdm_ch)
 		return -EAGAIN;
 	}
 
-	BUG_ON(mbo->bus_address == 0);
+	if (mbo->bus_address == 0) {
+		spin_unlock_irqrestore(&dim_lock, flags);
+		return -EFAULT;
+	}
 	if (!dim_enqueue_buffer(&hdm_ch->ch, mbo->bus_address, buf_size)) {
 		list_del(head->next);
 		spin_unlock_irqrestore(&dim_lock, flags);
-- 
2.33.0


  reply	other threads:[~2026-03-30 18:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 18:22 [PATCH v2 0/5] staging: most: dim2: replace BUG_ON() with graceful error handling grondon
2026-03-30 18:22 ` grondon [this message]
2026-03-30 18:22 ` [PATCH v2 2/5] staging: most: dim2: replace BUG_ON() in service_done_flag() grondon
2026-03-31 10:55   ` Dan Carpenter
2026-03-31 16:44     ` grondon
2026-03-31 19:40       ` Dan Carpenter
2026-04-01 10:09         ` grondon
2026-03-30 18:22 ` [PATCH v2 3/5] staging: most: dim2: replace BUG_ON() in configure_channel() grondon
2026-03-30 18:22 ` [PATCH v2 4/5] staging: most: dim2: replace BUG_ON() in enqueue() grondon
2026-03-30 18:22 ` [PATCH v2 5/5] staging: most: dim2: replace BUG_ON() in poison_channel() grondon

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=20260330182255.75241-2-grondon@gmail.com \
    --to=grondon@gmail.com \
    --cc=christian.gromm@microchip.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.