From patchwork Mon Dec 14 23:54:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ramos Falcon, Ernesto" X-Patchwork-Id: 67427 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBENsbxD014109 for ; Mon, 14 Dec 2009 23:54:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758419AbZLNXyg (ORCPT ); Mon, 14 Dec 2009 18:54:36 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755188AbZLNXyg (ORCPT ); Mon, 14 Dec 2009 18:54:36 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:54323 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754660AbZLNXyf convert rfc822-to-8bit (ORCPT ); Mon, 14 Dec 2009 18:54:35 -0500 Received: from dlep36.itg.ti.com ([157.170.170.91]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id nBENsZop030087 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 14 Dec 2009 17:54:35 -0600 Received: from dlep26.itg.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id nBENsYrZ024962 for ; Mon, 14 Dec 2009 17:54:34 -0600 (CST) Received: from dlee73.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id nBENsYFh014787 for ; Mon, 14 Dec 2009 17:54:34 -0600 (CST) Received: from dlee01.ent.ti.com ([157.170.170.12]) by dlee73.ent.ti.com ([157.170.170.88]) with mapi; Mon, 14 Dec 2009 17:54:34 -0600 From: "Ramos Falcon, Ernesto" To: "linux-omap@vger.kernel.org" Date: Mon, 14 Dec 2009 17:54:32 -0600 Subject: [PATCH] DSPBRIDGE: Undo allocation of resources in case of cp_to_usr fails. Thread-Topic: [PATCH] DSPBRIDGE: Undo allocation of resources in case of cp_to_usr fails. Thread-Index: Acp9GMhuAigE16upTP2asu6JzbEV4g== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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);