From patchwork Mon Feb 1 17:56:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ameya Palande X-Patchwork-Id: 76127 X-Patchwork-Delegate: omar.ramirez@ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o11Hv8Q6010659 for ; Mon, 1 Feb 2010 17:57:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754371Ab0BAR5H (ORCPT ); Mon, 1 Feb 2010 12:57:07 -0500 Received: from smtp.nokia.com ([192.100.105.134]:53998 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753877Ab0BAR5F (ORCPT ); Mon, 1 Feb 2010 12:57:05 -0500 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o11Huqkh007971; Mon, 1 Feb 2010 11:57:00 -0600 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Feb 2010 19:56:56 +0200 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Feb 2010 19:56:56 +0200 Received: from localhost.localdomain (esdhcp041217.research.nokia.com [172.21.41.217]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o11HuqoB032230; Mon, 1 Feb 2010 19:56:53 +0200 From: Ameya Palande To: omar.ramirez@ti.com Cc: nm@ti.com, linux-omap@vger.kernel.org, deepak.chitriki@ti.com Subject: [PATCH] DSPBRIDGE: MEM_VFree() cleanup Date: Mon, 1 Feb 2010 19:56:34 +0200 Message-Id: <48172f2f93a66f4d34c79aa6164236b01e706e3e.1265046944.git.ameya.palande@nokia.com> X-Mailer: git-send-email 1.6.3.3 X-OriginalArrivalTime: 01 Feb 2010 17:56:56.0496 (UTC) FILETIME=[F1AB1300:01CAA367] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 01 Feb 2010 17:57:08 +0000 (UTC) diff --git a/drivers/dsp/bridge/services/mem.c b/drivers/dsp/bridge/services/mem.c index dfe352d..c2887b3 100644 --- a/drivers/dsp/bridge/services/mem.c +++ b/drivers/dsp/bridge/services/mem.c @@ -456,35 +456,27 @@ void MEM_FlushCache(void *pMemBuf, u32 cBytes, s32 FlushType) void MEM_VFree(IN void *pMemBuf) { #ifdef MEM_CHECK - struct memInfo *pMem = (void *)((u32)pMemBuf - sizeof(struct memInfo)); + struct memInfo *pMem; #endif - - DBC_Require(pMemBuf != NULL); - GT_1trace(MEM_debugMask, GT_ENTER, "MEM_VFree: pMemBufs 0x%x\n", - pMemBuf); - - if (pMemBuf) { -#ifndef MEM_CHECK - vfree(pMemBuf); + pMemBuf); +#ifdef MEM_CHECK + if (!pMemBuf) { + GT_1trace(MEM_debugMask, GT_7CLASS, + "Invalid allocation or Buffer underflow\n"); + return; + } + pMem = (void *)((u32)pMemBuf - sizeof(struct memInfo)); + if (pMem && pMem->dwSignature == memInfoSign) { + spin_lock(&mMan.lock); + MLST_RemoveElem(&mMan.lst, (struct list_head *)pMem); + spin_unlock(&mMan.lock); + pMem->dwSignature = 0; + vfree(pMem); + } #else - if (pMem) { - if (pMem->dwSignature == memInfoSign) { - spin_lock(&mMan.lock); - MLST_RemoveElem(&mMan.lst, - (struct list_head *)pMem); - spin_unlock(&mMan.lock); - pMem->dwSignature = 0; - vfree(pMem); - } else { - GT_1trace(MEM_debugMask, GT_7CLASS, - "Invalid allocation or " - "Buffer underflow at %x\n", - (u32) pMem + sizeof(struct memInfo)); - } - } + vfree(pMemBuf); #endif - } } /*