From 081a450987752d20158a22eb632814d74460f3e1 Mon Sep 17 00:00:00 2001 From: Mandy Lavi Date: Sun, 25 May 2014 18:25:41 +0300 Subject: fmd: fix potentially uninitialized pointer Signed-off-by: Mandy Lavi Change-Id: I5ef4f9bd5f0cb1d9b43d8bcc4ac7b1efb3b0bd38 Reviewed-on: http://git.am.freescale.net:8181/12856 Reviewed-by: Nir Erez Reviewed-by: Jose Rivera Tested-by: Jose Rivera (cherry picked from commit 39967816be45a10552e25ec27e2d20de0a466534) Reviewed-on: http://git.am.freescale.net:8181/13060 diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/Pcd/fm_cc.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/Pcd/fm_cc.c index 2e6a0e0..09eec69 100644 --- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/Pcd/fm_cc.c +++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/Pcd/fm_cc.c @@ -924,18 +924,16 @@ static t_Error DoDynamicChange(t_Handle h_FmPcd, memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams)); - numOfModifiedPtr = (uint8_t)LIST_NumOfObjs(h_OldPointersLst); - - if (numOfModifiedPtr) - { - - p_PosNew = LIST_FIRST(h_NewPointersLst); - - /* Invoke host-command to copy from the new Ad to existing Ads */ - err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst, p_AdditionalParams, useShadowStructs); - if (err) - RETURN_ERROR(MAJOR, err, NO_MSG); - } + numOfModifiedPtr = (uint8_t)LIST_NumOfObjs(h_OldPointersLst); + + + p_PosNew = LIST_FIRST(h_NewPointersLst); + + /* Invoke host-command to copy from the new Ad to existing Ads */ + err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst, p_AdditionalParams, useShadowStructs); + if (err) + RETURN_ERROR(MAJOR, err, NO_MSG); + if (useShadowStructs) { /* When the host-command above has ended, the old structures are 'free'and we can update @@ -953,25 +951,30 @@ static t_Error DoDynamicChange(t_Handle h_FmPcd, p_AdditionalParams->p_AdTableNew, (uint32_t)((p_CcNode->maxNumOfKeys + 1) * FM_PCD_CC_AD_ENTRY_SIZE)); - /* Retrieve the address of the allocated Ad */ - p_CcNodeInfo = CC_NODE_F_OBJECT(p_PosNew); - h_Ad = p_CcNodeInfo->h_CcNode; - /* Build a new Ad that holds the old (now updated) structures */ p_AdditionalParams->p_KeysMatchTableNew = p_AdditionalParams->p_KeysMatchTableOld; p_AdditionalParams->p_AdTableNew = p_AdditionalParams->p_AdTableOld; - nextEngineParams.nextEngine = e_FM_PCD_CC; - nextEngineParams.params.ccParams.h_CcNode = (t_Handle)p_CcNode; - - BuildNewAd(h_Ad, p_AdditionalParams, p_CcNode, &nextEngineParams); + if (numOfModifiedPtr) + { + /* Retrieve the address of the allocated Ad */ + p_CcNodeInfo = CC_NODE_F_OBJECT(p_PosNew); + h_Ad = p_CcNodeInfo->h_CcNode; + nextEngineParams.nextEngine = e_FM_PCD_CC; + nextEngineParams.params.ccParams.h_CcNode = (t_Handle)p_CcNode; + /* Build a new Ad that holds the old (now updated) structures */ + BuildNewAd(h_Ad, p_AdditionalParams, p_CcNode, &nextEngineParams); + } + /* HC to copy from the new Ad (old updated structures) to current Ad (uses shadow structures) */ err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst, p_AdditionalParams, useShadowStructs); if (err) RETURN_ERROR(MAJOR, err, NO_MSG); } + + err = ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst, h_NewPointersLst, -- cgit v0.10.2