diff mbox

[4/8] dspbridge: Check pointer returned by MEM_Calloc()

Message ID 1251375541-1866-5-git-send-email-andy.shevchenko@gmail.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Andy Shevchenko Aug. 27, 2009, 12:18 p.m. UTC
From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>

In case of NULL return DSP_EMEMORY status instead of DSP_SOK.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
---
 drivers/dsp/bridge/rmgr/drv.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

Comments

Guzman Lugo, Fernando Aug. 31, 2009, 8:19 p.m. UTC | #1
Acked-by: Fernando Guzman Lugo <x0095840@ti.com>


>-----Original Message-----
>From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
>owner@vger.kernel.org] On Behalf Of Andy Shevchenko
>Sent: Thursday, August 27, 2009 7:19 AM
>To: linux-omap@vger.kernel.org
>Cc: Andy Shevchenko
>Subject: [PATCH 4/8] dspbridge: Check pointer returned by MEM_Calloc()
>
>From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
>
>In case of NULL return DSP_EMEMORY status instead of DSP_SOK.
>
>Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
>---
> drivers/dsp/bridge/rmgr/drv.c |   23 +++++++++++++----------
> 1 files changed, 13 insertions(+), 10 deletions(-)
>
>diff --git a/drivers/dsp/bridge/rmgr/drv.c b/drivers/dsp/bridge/rmgr/drv.c
>index 691c727..bedc34c 100644
>--- a/drivers/dsp/bridge/rmgr/drv.c
>+++ b/drivers/dsp/bridge/rmgr/drv.c
>@@ -1571,17 +1571,18 @@ static DSP_STATUS RequestBridgeResources(u32
>dwContext, s32 bRequest)
> 		/* Releasing resources by deleting the registry key  */
> 		dwBuffSize = sizeof(struct CFG_HOSTRES);
> 		pResources = MEM_Calloc(dwBuffSize, MEM_NONPAGED);
>-		if (DSP_FAILED(REG_GetValue(NULL, (char *)driverExt->szString,
>-		   CURRENTCONFIG, (u8 *)pResources, &dwBuffSize))) {
>-			status = CFG_E_RESOURCENOTAVAIL;
>-			GT_0trace(curTrace, GT_1CLASS,
>-				 "REG_GetValue Failed \n");
>-		} else {
>-			GT_0trace(curTrace, GT_1CLASS,
>-				 "REG_GetValue Succeeded \n");
>-		}
>-
> 		if (pResources != NULL) {
>+			if (DSP_FAILED(REG_GetValue(NULL,
>+			    (char *) driverExt->szString,
>+			    CURRENTCONFIG, (u8 *) pResources, &dwBuffSize))) {
>+				status = CFG_E_RESOURCENOTAVAIL;
>+				GT_0trace(curTrace, GT_1CLASS,
>+					 "REG_GetValue Failed \n");
>+			} else {
>+				GT_0trace(curTrace, GT_1CLASS,
>+					 "REG_GetValue Succeeded \n");
>+			}
>+
> 			dwBuffSize = sizeof(shm_size);
> 			status = REG_GetValue(NULL, CURRENTCONFIG, SHMSIZE,
> 				(u8 *)&shm_size, &dwBuffSize);
>@@ -1646,6 +1647,8 @@ static DSP_STATUS RequestBridgeResources(u32
>dwContext, s32 bRequest)
> 				 (u32)dwBuffSize);
> 			/*  Set all the other entries to NULL */
> 			MEM_Free(pResources);
>+		} else {
>+			status = DSP_EMEMORY;
> 		}
> 		GT_0trace(curTrace, GT_ENTER, " <- RequestBridgeResources \n");
> 		return status;
>--
>1.5.6.5
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/dsp/bridge/rmgr/drv.c b/drivers/dsp/bridge/rmgr/drv.c
index 691c727..bedc34c 100644
--- a/drivers/dsp/bridge/rmgr/drv.c
+++ b/drivers/dsp/bridge/rmgr/drv.c
@@ -1571,17 +1571,18 @@  static DSP_STATUS RequestBridgeResources(u32 dwContext, s32 bRequest)
 		/* Releasing resources by deleting the registry key  */
 		dwBuffSize = sizeof(struct CFG_HOSTRES);
 		pResources = MEM_Calloc(dwBuffSize, MEM_NONPAGED);
-		if (DSP_FAILED(REG_GetValue(NULL, (char *)driverExt->szString,
-		   CURRENTCONFIG, (u8 *)pResources, &dwBuffSize))) {
-			status = CFG_E_RESOURCENOTAVAIL;
-			GT_0trace(curTrace, GT_1CLASS,
-				 "REG_GetValue Failed \n");
-		} else {
-			GT_0trace(curTrace, GT_1CLASS,
-				 "REG_GetValue Succeeded \n");
-		}
-
 		if (pResources != NULL) {
+			if (DSP_FAILED(REG_GetValue(NULL,
+			    (char *) driverExt->szString,
+			    CURRENTCONFIG, (u8 *) pResources, &dwBuffSize))) {
+				status = CFG_E_RESOURCENOTAVAIL;
+				GT_0trace(curTrace, GT_1CLASS,
+					 "REG_GetValue Failed \n");
+			} else {
+				GT_0trace(curTrace, GT_1CLASS,
+					 "REG_GetValue Succeeded \n");
+			}
+
 			dwBuffSize = sizeof(shm_size);
 			status = REG_GetValue(NULL, CURRENTCONFIG, SHMSIZE,
 				(u8 *)&shm_size, &dwBuffSize);
@@ -1646,6 +1647,8 @@  static DSP_STATUS RequestBridgeResources(u32 dwContext, s32 bRequest)
 				 (u32)dwBuffSize);
 			/*  Set all the other entries to NULL */
 			MEM_Free(pResources);
+		} else {
+			status = DSP_EMEMORY;
 		}
 		GT_0trace(curTrace, GT_ENTER, " <- RequestBridgeResources \n");
 		return status;