[PATCH v2 3/5] staging: most: dim2: replace BUG_ON() in configure_channel()

From: grondon

Date: Mon Mar 30 2026 - 14:27:33 EST


From: Gabriel Rondon <grondon@xxxxxxxxx>

Replace BUG_ON() range check on ch_idx with a return of -EINVAL.

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

Signed-off-by: Gabriel Rondon <grondon@xxxxxxxxx>
---
drivers/staging/most/dim2/dim2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
index b820c3647..0b80f313a 100644
--- a/drivers/staging/most/dim2/dim2.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -457,7 +457,8 @@ static int configure_channel(struct most_interface *most_iface, int ch_idx,
int const ch_addr = ch_idx * 2 + 2;
struct hdm_channel *const hdm_ch = dev->hch + ch_idx;

- BUG_ON(ch_idx < 0 || ch_idx >= DMA_CHANNELS);
+ if (ch_idx < 0 || ch_idx >= DMA_CHANNELS)
+ return -EINVAL;

if (hdm_ch->is_initialized)
return -EPERM;
--
2.33.0