]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: most: dim2: replace BUG_ON() in try_start_dim_transfer()
authorGabriel Rondon <grondon@gmail.com>
Mon, 30 Mar 2026 18:22:51 +0000 (19:22 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 31 Mar 2026 08:46:38 +0000 (10:46 +0200)
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>
drivers/staging/most/dim2/dim2.c

index 66617e89e02834a19fdd2d2a8196773a9043667a..48315f8cd6bb0d819afd957bbca93ece95567261 100644 (file)
@@ -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);