staging: gdm72xx: return -EINVAL instead of BUG_ON for invalid data length
authorBen Chan <benchan@chromium.org>
Sat, 28 Jun 2014 06:17:24 +0000 (23:17 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 29 Jun 2014 21:41:04 +0000 (14:41 -0700)
This patch changes gdm_usb_send() and gdm_sdio_send() to return -EINVAL instead
of calling BUG_ON if an invalid data length is passed to the functions.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Michalis Pappas <mpappas@fastmail.fm>
Signed-off-by: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gdm72xx/gdm_sdio.c
drivers/staging/gdm72xx/gdm_usb.c

index 0c6a3eb00e84541a28c1a3dc80e545c0be2ff0b9..9d2de6ff79030d7cb373b5d970af34decc77bf3d 100644 (file)
@@ -390,7 +390,8 @@ static int gdm_sdio_send(void *priv_dev, void *data, int len,
        u16 cmd_evt;
        unsigned long flags;
 
-       BUG_ON(len > TX_BUF_SIZE - TYPE_A_HEADER_SIZE);
+       if (len > TX_BUF_SIZE - TYPE_A_HEADER_SIZE)
+               return -EINVAL;
 
        spin_lock_irqsave(&tx->lock, flags);
 
index cd8e6e483e70ca9f4bfd91611d936810790f7a0a..971976cd8d0cac95be2571546675093120a8b6cd 100644 (file)
@@ -312,7 +312,8 @@ static int gdm_usb_send(void *priv_dev, void *data, int len,
                return -ENODEV;
        }
 
-       BUG_ON(len > TX_BUF_SIZE - padding - 1);
+       if (len > TX_BUF_SIZE - padding - 1)
+               return -EINVAL;
 
        spin_lock_irqsave(&tx->lock, flags);