dsp56k: prevent a harmless underflow
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 13 Jul 2016 10:11:19 +0000 (13:11 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Jul 2016 07:21:53 +0000 (16:21 +0900)
There is a mistake here where we don't allow "len" to be zero but we
allow negative lengths.  It's basically harmless in this case, but the
underflow makes my static checker complain.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/dsp56k.c

index 8bf70e8c3f790635328fbd79ae75331701c4f1a0..50aa9ba91f255c6a99f1b385ecd065cbc5541d24 100644 (file)
@@ -325,7 +325,7 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
                        if(get_user(bin, &binary->bin) < 0)
                                return -EFAULT;
                
-                       if (len == 0) {
+                       if (len <= 0) {
                                return -EINVAL;      /* nothing to upload?!? */
                        }
                        if (len > DSP56K_MAX_BINARY_LENGTH) {