# HG changeset patch # User Michael Spacefalcon # Date 1403835867 0 # Node ID dcb543907cbbcab990381cffb253fee442a93807 # Parent 6e6d4c1ec7333619aa3a717dd877a81a68cd93a5 os_mem_fl.c: os_CreatePartitionPool(): fixed error check logic diff -r 6e6d4c1ec733 -r dcb543907cbb gsm-fw/gpf/osl/os_mem_fl.c --- a/gsm-fw/gpf/osl/os_mem_fl.c Fri Jun 27 01:20:23 2014 +0000 +++ b/gsm-fw/gpf/osl/os_mem_fl.c Fri Jun 27 02:24:27 2014 +0000 @@ -306,17 +306,13 @@ sts = NU_Obtain_Semaphore(&MemSemCB, NU_SUSPEND); j = 0; - part_group = 0; part_group_head = 0; for (i = 0; i <= MaxPoolGroups; i++) { - if (!PartGrpTable[i].grp_head || !PartGrpTable[i].name[0]) { - part_group = i; + if (!PartGrpTable[i].grp_head || !PartGrpTable[i].name[0]) break; - } if (!strncmp(GroupName, PartGrpTable[i].name, RESOURCE_NAMELEN - 1)) { part_group_head = PartGrpTable[i].grp_head; - part_group = i; opool = part_group_head; j++; while (opool->next) { @@ -326,12 +322,20 @@ break; } } - if (part_group > MaxPoolGroups) { + /* + * This error check logic has been modified from the original + * faithful reconstruction by Space Falcon. In the original code + * if MaxPoolGroups had been reached and the for loop above + * never broke, the code would proceed to overwrite pool #0 + * instead of catching the error. + */ + if (i > MaxPoolGroups) { release_sem_return_err: if (sts == NU_SUCCESS) NU_Release_Semaphore(&MemSemCB); return(OS_ERROR); } + part_group = i; if (!part_group_head) { strncpy(PartGrpTable[part_group].name, GroupName, RESOURCE_NAMELEN);