From patchwork Tue Sep 1 07:59:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 44998 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8180u55011363 for ; Tue, 1 Sep 2009 08:00:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752079AbZIAIAH (ORCPT ); Tue, 1 Sep 2009 04:00:07 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753176AbZIAIAG (ORCPT ); Tue, 1 Sep 2009 04:00:06 -0400 Received: from smtp.nokia.com ([192.100.122.233]:34437 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752786AbZIAIAF (ORCPT ); Tue, 1 Sep 2009 04:00:05 -0400 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n817xmjF022891 for ; Tue, 1 Sep 2009 10:59:52 +0300 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 1 Sep 2009 10:59:53 +0300 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 1 Sep 2009 10:59:52 +0300 Received: from dilbert.research.nokia.com (esdhcp034223.research.nokia.com [172.21.34.223]) by mgw-sa02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n817xpHq031202 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Tue, 1 Sep 2009 10:59:52 +0300 Received: from andy by dilbert.research.nokia.com with local (Exim 4.69) (envelope-from ) id 1MiOHJ-0003kp-Km; Tue, 01 Sep 2009 10:59:45 +0300 From: Andy Shevchenko To: linux-omap@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH] dspbridge: Check pointer before usage Date: Tue, 1 Sep 2009 10:59:45 +0300 Message-Id: <1251791985-14412-1-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <496565EC904933469F292DDA3F1663E602A5EF2E95@dlee06.ent.ti.com> References: <496565EC904933469F292DDA3F1663E602A5EF2E95@dlee06.ent.ti.com> X-OriginalArrivalTime: 01 Sep 2009 07:59:52.0990 (UTC) FILETIME=[2FFE1BE0:01CA2ADA] Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Andy Shevchenko Theoretically list could be deleted before we go into the for loop. Additionally we could delete list immediately if it becomes empty. Signed-off-by: Andy Shevchenko --- drivers/dsp/bridge/rmgr/drv.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/dsp/bridge/rmgr/drv.c b/drivers/dsp/bridge/rmgr/drv.c index d21071c..9f726a6 100644 --- a/drivers/dsp/bridge/rmgr/drv.c +++ b/drivers/dsp/bridge/rmgr/drv.c @@ -1545,18 +1545,23 @@ DSP_STATUS DRV_ReleaseResources(u32 dwContext, struct DRV_OBJECT *hDrvObject) for (pszdevNode = (struct DRV_EXT *)DRV_GetFirstDevExtension(); pszdevNode != NULL; pszdevNode = (struct DRV_EXT *) DRV_GetNextDevExtension((u32)pszdevNode)) { + if (!pDRVObject->devNodeString) + /* List already deleted */ + break; + if ((u32)pszdevNode == dwContext) { /* Found it */ /* Delete from the Driver object list */ LST_RemoveElem(pDRVObject->devNodeString, - (struct LST_ELEM *)pszdevNode); + (struct LST_ELEM *) pszdevNode); MEM_Free((void *) pszdevNode); - break; } + /* Delete the List if it is empty */ if (LST_IsEmpty(pDRVObject->devNodeString)) { LST_Delete(pDRVObject->devNodeString); pDRVObject->devNodeString = NULL; + break; } } return status;