[PATCH v3 1/2] staging: most: dim2: replace BUG_ON() in poison_channel()
From: Nguyen Duc Thinh
Date: Sun Apr 12 2026 - 09:01:19 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>
Link: https://patch.msgid.link/20260330182255.75241-6-grondon@xxxxxxxxx
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
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 23230a32c2cb..7953d4626752 100644
--- a/drivers/staging/most/dim2/dim2.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -647,7 +647,8 @@ static int poison_channel(struct most_interface *most_iface, int ch_idx)
u8 hal_ret;
int ret = 0;
- 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.47.3