>From 537bfe5dd95e7b619a578be8d2ac541bc5c0d6ed Mon Sep 17 00:00:00 2001 From: ernesto <x0076199@x0076199-desktop.(none)> Date: Mon, 14 Dec 2009 17:46:06 -0600 Subject: [PATCH] DSPBRIDGE: Undo allocation of resources in case of cp_to_usr fails. Release resources allocated during MAP, Node Allocation, STRM Buf Allocation in the case of cp_to_usr fails. Signed-off-by: Ernesto Ramos <ernesto@xxxxxx> --- drivers/dsp/bridge/pmgr/wcd.c | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/dsp/bridge/pmgr/wcd.c b/drivers/dsp/bridge/pmgr/wcd.c index c19b715..e90eeda 100644 --- a/drivers/dsp/bridge/pmgr/wcd.c +++ b/drivers/dsp/bridge/pmgr/wcd.c @@ -1043,8 +1043,11 @@ u32 PROCWRAP_Map(union Trapped_Args *args, void *pr_ctxt) args->ARGS_PROC_MAPMEM.pReqAddr, &pMapAddr, args->ARGS_PROC_MAPMEM.ulMapAttr, pr_ctxt); if (DSP_SUCCEEDED(status)) { - if (put_user(pMapAddr, args->ARGS_PROC_MAPMEM.ppMapAddr)) + if (put_user(pMapAddr, args->ARGS_PROC_MAPMEM.ppMapAddr)) { + status = PROC_UnMap(args->ARGS_PROC_MAPMEM.hProcessor, + &pMapAddr, pr_ctxt); status = DSP_EINVALIDARG; + } } return status; @@ -1194,7 +1197,13 @@ u32 NODEWRAP_Allocate(union Trapped_Args *args, void *pr_ctxt) &nodeId, (struct DSP_CBDATA *)pArgs, pAttrIn, &hNode, pr_ctxt); } - cp_to_usr(args->ARGS_NODE_ALLOCATE.phNode, &hNode, status, 1); + if (DSP_SUCCEEDED(status)) { + cp_to_usr(args->ARGS_NODE_ALLOCATE.phNode, &hNode, status, 1); + if (DSP_FAILED(status)) { + status = NODE_Delete(hNode, pr_ctxt); + status = DSP_EPOINTER; + } + } func_cont: if (pArgs) MEM_Free(pArgs); @@ -1528,8 +1537,16 @@ u32 STRMWRAP_AllocateBuffer(union Trapped_Args *args, void *pr_ctxt) status = STRM_AllocateBuffer(args->ARGS_STRM_ALLOCATEBUFFER.hStream, args->ARGS_STRM_ALLOCATEBUFFER.uSize, apBuffer, uNumBufs, pr_ctxt); - cp_to_usr(args->ARGS_STRM_ALLOCATEBUFFER.apBuffer, apBuffer, status, - uNumBufs); + if (DSP_SUCCEEDED(status)) { + cp_to_usr(args->ARGS_STRM_ALLOCATEBUFFER.apBuffer, apBuffer, + status, uNumBufs); + if (DSP_FAILED(status)) { + status = STRM_FreeBuffer( + args->ARGS_STRM_ALLOCATEBUFFER.hStream, + apBuffer, uNumBufs, pr_ctxt); + status = DSP_EPOINTER; + } + } if (apBuffer) MEM_Free(apBuffer); -- 1.5.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html