From: Hung N. <hun...@de...> - 2015-09-12 12:13:55
|
Hi Zoran, An alternative solution is to append 'rparams' to: 'evt->info.admOpRsp.parms' in immnd_evt_proc_admop_rsp() 'evt->info.admOpReq.params' in immnd_evt_proc_admop() and then just let the immnd_evt_destroy() do the job. If you still want to free the memory immediately after sending, I think it's better to follow the pattern in immnd_evt_destroy() while (rparams) { IMMSV_ADMIN_OPERATION_PARAM *p = rparams; rparams = p->next; if (p->paramName.buf) { free(p->paramName.buf); p->paramName.buf = NULL; p->paramName.size = 0; } immsv_evt_free_att_val(&(p->paramBuffer), p->paramType); p->next = NULL; free(p); } Best Regards, Hùng Nguyễn - DEK Technologies ------------------------------------------------------------------------ *From:* Zoran Milinkovic *Sent:* Saturday, September 12, 2015 5:42PM *To:* Neelakanta Reddy *Cc:* Opensaf-devel *Subject:* [devel] [PATCH 1 of 1] imm: fix memory leak in display resources [#1477] osaf/services/saf/immsv/immnd/immnd_evt.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) The patch releases allocated memory for the result of admin op for display resources diff --git a/osaf/services/saf/immsv/immnd/immnd_evt.c b/osaf/services/saf/immsv/immnd/immnd_evt.c --- a/osaf/services/saf/immsv/immnd/immnd_evt.c +++ b/osaf/services/saf/immsv/immnd/immnd_evt.c @@ -4726,6 +4726,7 @@ static uint32_t immnd_evt_proc_admop_rsp */ bool displayRes=false; IMMSV_ADMIN_OPERATION_PARAM *rparams= NULL; + IMMSV_ADMIN_OPERATION_PARAM *prev; struct ImmsvAdminOperationParam *params = evt->info.admOpRsp.parms; SaAisErrorT err = evt->info.admOpRsp.error; SaAisErrorT result = evt->info.admOpRsp.result; @@ -4768,6 +4769,19 @@ static uint32_t immnd_evt_proc_admop_rsp rc = immnd_mds_send_rsp(cb, &(cl_node->tmpSinfo), &send_evt); TRACE_2("SYNC REPLY SENT rc:%u", rc); } + + // Free memory + while(rparams) { + if(rparams->paramType == SA_IMM_ATTR_SASTRINGT) { + free(rparams->paramBuffer.val.x.buf); + } + free(rparams->paramName.buf); + + prev = rparams; + rparams = rparams->next; + free(prev); + } + if (rc != NCSCC_RC_SUCCESS) { LOG_ER("Failure in sending reply for admin-op over MDS"); } @@ -5043,6 +5057,7 @@ static void immnd_evt_proc_admop(IMMND_C uint32_t rc = NCSCC_RC_SUCCESS; SaAisErrorT result = SA_AIS_OK; IMMSV_ADMIN_OPERATION_PARAM *rparams= NULL; + IMMSV_ADMIN_OPERATION_PARAM *prev; osafassert(!pbeExpected); TRACE("Ok reply for internally handled adminOp when PBE not configured"); @@ -5077,6 +5092,18 @@ static void immnd_evt_proc_admop(IMMND_C } } + // Free memory + while(rparams) { + if(rparams->paramType == SA_IMM_ATTR_SASTRINGT) { + free(rparams->paramBuffer.val.x.buf); + } + free(rparams->paramName.buf); + + prev = rparams; + rparams = rparams->next; + free(prev); + } + if (rc != NCSCC_RC_SUCCESS) { LOG_ER("Failure in sending reply for admin-op over MDS"); } ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list Ope...@li... https://lists.sourceforge.net/lists/listinfo/opensaf-devel |