Skip to contentSkip to conversation

staging: atomisp: potential underflow in atomisp_get_metadata_by_type()

PATCH In review Dan Carpenter 2 participants 2 messages Mar 13, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: atomisp: potential underflow in atomisp_get_metadata_by_type()

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")
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c +1 -1
index d9a5c24633cb..0d77ebc5c865 100644
@@ -3005,7 +3005,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() */
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

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.

Can do but the kernel assumes GNU C everywhere else.

Alan