Moved some value checks to right positions to prevent
buffer flow, which may be possible before. Previously
these value checks are in an else statement which may
not be executed.
Change-Id: I02dbecd074183581a6bdae6377097bc004bd3d3c
CRs-fixed:
1102936
Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
goto inval;
field = report->field[uref->field_index];
+ }
- if (cmd == HIDIOCGCOLLECTIONINDEX) {
- if (uref->usage_index >= field->maxusage)
- goto inval;
- } else if (uref->usage_index >= field->report_count)
+ if (cmd == HIDIOCGCOLLECTIONINDEX) {
+ if (uref->usage_index >= field->maxusage)
goto inval;
- }
+ } else if (uref->usage_index >= field->report_count)
+ goto inval;
if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
(uref_multi->num_values > HID_MAX_MULTI_USAGES ||