Skip to content

Commit f3dc673

Browse files
gabrielrondongregkh
authored andcommitted
staging: most: dim2: replace BUG_ON() in try_start_dim_transfer()
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> Link: https://patch.msgid.link/20260330182255.75241-2-grondon@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f019e98 commit f3dc673

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • drivers/staging/most/dim2

drivers/staging/most/dim2/dim2.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ static int try_start_dim_transfer(struct hdm_channel *hdm_ch)
165165
unsigned long flags;
166166
struct dim_ch_state st;
167167

168-
BUG_ON(!hdm_ch);
169-
BUG_ON(!hdm_ch->is_initialized);
168+
if (!hdm_ch || !hdm_ch->is_initialized)
169+
return -EINVAL;
170170

171171
spin_lock_irqsave(&dim_lock, flags);
172172
if (list_empty(head)) {
@@ -187,7 +187,10 @@ static int try_start_dim_transfer(struct hdm_channel *hdm_ch)
187187
return -EAGAIN;
188188
}
189189

190-
BUG_ON(mbo->bus_address == 0);
190+
if (mbo->bus_address == 0) {
191+
spin_unlock_irqrestore(&dim_lock, flags);
192+
return -EFAULT;
193+
}
191194
if (!dim_enqueue_buffer(&hdm_ch->ch, mbo->bus_address, buf_size)) {
192195
list_del(head->next);
193196
spin_unlock_irqrestore(&dim_lock, flags);

0 commit comments

Comments
 (0)