Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: bcm: fix possible memory leak of 'pstAddIndication' in CmHost.c and removes a whitespace

Memory is being allocated by kmalloc and stored in
variable pstAddIndication. However, this memory is
not being freed in all cases. Therefore, this patch
frees it on several exit paths. This patch also
removes a whitespace.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kevin McKinney and committed by
Greg Kroah-Hartman
cc55bb03 07b99cf5

+20 -7
+20 -7
drivers/staging/bcm/CmHost.c
··· 1399 1399 /* AUTHORIZED SET */ 1400 1400 pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *) 1401 1401 GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); 1402 - if (!pstAddIndication->psfAuthorizedSet) 1402 + if (!pstAddIndication->psfAuthorizedSet) { 1403 + kfree(pstAddIndication); 1403 1404 return 0; 1405 + } 1404 1406 1405 1407 if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAuthorizedSet, 1406 - (ULONG)pstAddIndication->psfAuthorizedSet) != 1) 1408 + (ULONG)pstAddIndication->psfAuthorizedSet) != 1) { 1409 + kfree(pstAddIndication); 1407 1410 return 0; 1411 + } 1408 1412 1409 1413 /* this can't possibly be right */ 1410 1414 pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfAuthorizedSet); ··· 1424 1420 AddRequest.psfParameterSet = pstAddIndication->psfAuthorizedSet; 1425 1421 (*puBufferLength) = sizeof(stLocalSFAddRequest); 1426 1422 memcpy(pvBuffer, &AddRequest, sizeof(stLocalSFAddRequest)); 1423 + kfree(pstAddIndication); 1427 1424 return 1; 1428 1425 } 1429 1426 ··· 1441 1436 /* ADMITTED SET */ 1442 1437 pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *) 1443 1438 GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); 1444 - if (!pstAddIndication->psfAdmittedSet) 1439 + if (!pstAddIndication->psfAdmittedSet) { 1440 + kfree(pstAddIndication); 1445 1441 return 0; 1446 - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAdmittedSet, (ULONG)pstAddIndication->psfAdmittedSet) != 1) 1442 + } 1443 + if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAdmittedSet, (ULONG)pstAddIndication->psfAdmittedSet) != 1) { 1444 + kfree(pstAddIndication); 1447 1445 return 0; 1446 + } 1448 1447 1449 1448 pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfAdmittedSet); 1450 1449 1451 1450 /* ACTIVE SET */ 1452 1451 pstAddIndication->psfActiveSet = (stServiceFlowParamSI *) 1453 1452 GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); 1454 - if (!pstAddIndication->psfActiveSet) 1453 + if (!pstAddIndication->psfActiveSet) { 1454 + kfree(pstAddIndication); 1455 1455 return 0; 1456 - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfActiveSet, (ULONG)pstAddIndication->psfActiveSet) != 1) 1456 + } 1457 + if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfActiveSet, (ULONG)pstAddIndication->psfActiveSet) != 1) { 1458 + kfree(pstAddIndication); 1457 1459 return 0; 1460 + } 1458 1461 1459 1462 pstAddIndication->psfActiveSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfActiveSet); 1460 1463 ··· 1857 1844 Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; 1858 1845 Adapter->PackInfo[uiSearchRuleIndex].bValid = FALSE; 1859 1846 Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0; 1860 - kfree(pstAddIndication); 1847 + kfree(pstAddIndication); 1861 1848 } else if (psfLocalSet->bValid && (pstChangeIndication->u8CC == 0)) { 1862 1849 Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pstChangeIndication->u16VCID); 1863 1850 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "CC field is %d bvalid = %d\n",