staging: atomisp: potential underflow in atomisp_get_metadata_by_type()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 13 Mar 2017 12:34:14 +0000 (15:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Mar 2017 00:00:37 +0000 (08:00 +0800)
md_type is an enum.  On my tests, GCC treats it as unsigned but
according to the C standard it's an implementation dependant thing so we
should check for negatives.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c

index 97207569f14ba2437d5c7391552e206f1e043ff2..1ee99d0e43ee116dd0adc01da5ed312889d72292 100644 (file)
@@ -3004,7 +3004,7 @@ int atomisp_get_metadata_by_type(struct atomisp_sub_device *asd, int flag,
                return 0;
 
        md_type = md->type;
-       if (md_type >= ATOMISP_METADATA_TYPE_NUM)
+       if (md_type < 0 || md_type >= ATOMISP_METADATA_TYPE_NUM)
                return -EINVAL;
 
        /* This is done in the atomisp_buf_done() */