From patchwork Mon Feb 1 16:57:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ameya Palande X-Patchwork-Id: 76118 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 o11GwELx010414 for ; Mon, 1 Feb 2010 16:58:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751160Ab0BAQ6N (ORCPT ); Mon, 1 Feb 2010 11:58:13 -0500 Received: from smtp.nokia.com ([192.100.122.233]:37877 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750958Ab0BAQ6N (ORCPT ); Mon, 1 Feb 2010 11:58:13 -0500 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o11GvNF7001641; Mon, 1 Feb 2010 18:58:06 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Feb 2010 18:58:04 +0200 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Feb 2010 18:58:04 +0200 Received: from localhost.localdomain (esdhcp041217.research.nokia.com [172.21.41.217]) by mgw-sa02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o11Gw32a020149; Mon, 1 Feb 2010 18:58:03 +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_Free() cleanup Date: Mon, 1 Feb 2010 18:57:45 +0200 Message-Id: <577decfb1227d1772fb5a92f796a101464be2b50.1265038929.git.ameya.palande@nokia.com> X-Mailer: git-send-email 1.6.3.3 X-OriginalArrivalTime: 01 Feb 2010 16:58:04.0480 (UTC) FILETIME=[B86C3400:01CAA35F] 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 16:58:14 +0000 (UTC) diff --git a/drivers/dsp/bridge/services/mem.c b/drivers/dsp/bridge/services/mem.c index cee646a..dfe352d 100644 --- a/drivers/dsp/bridge/services/mem.c +++ b/drivers/dsp/bridge/services/mem.c @@ -495,35 +495,27 @@ void MEM_VFree(IN void *pMemBuf) void MEM_Free(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_Free: pMemBufs 0x%x\n", pMemBuf); - - if (pMemBuf) { -#ifndef MEM_CHECK - kfree(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; + kfree(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; - kfree(pMem); - } else { - GT_1trace(MEM_debugMask, GT_7CLASS, - "Invalid allocation or " - "Buffer underflow at %x\n", - (u32) pMem + sizeof(struct memInfo)); - } - } + kfree(pMemBuf); #endif - } } /*