diff mbox

[5/5] dspbridge: static code analysis issues - don't dereference NULL

Message ID 1249036768-754-5-git-send-email-Hiroshi.DOYU@nokia.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Hiroshi DOYU July 31, 2009, 10:39 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/dsp/bridge/pmgr/dbll.c b/drivers/dsp/bridge/pmgr/dbll.c
index c57f557..7c3cd40 100644
--- a/drivers/dsp/bridge/pmgr/dbll.c
+++ b/drivers/dsp/bridge/pmgr/dbll.c
@@ -1481,6 +1481,7 @@  static int writeMem(struct Dynamic_Loader_Initialize *this, void *buf,
 {
 	struct DBLLInit *pInit = (struct DBLLInit *)this;
 	struct DBLL_LibraryObj *lib;
+	struct DBLL_TarObj *pTarget;
 	struct DBLL_SectInfo sectInfo;
 	u32 memType;
 	bool retVal = true;
@@ -1491,20 +1492,24 @@  static int writeMem(struct Dynamic_Loader_Initialize *this, void *buf,
 
 	memType = (DLOAD_SECTION_TYPE(info->type) == DLOAD_TEXT) ? DBLL_CODE :
 		  DBLL_DATA;
-	if (lib != NULL) {
-		retVal = (*lib->pTarget->attrs.write)(lib->pTarget->
-			attrs.wHandle, addr, buf, nBytes, memType);
-	}
-	if (lib->pTarget->attrs.logWrite) {
-		sectInfo.name = info->name;
-		sectInfo.runAddr = info->run_addr;
-		sectInfo.loadAddr = info->load_addr;
-		sectInfo.size = info->size;
-		sectInfo.type = memType;
-		/* Pass the information about what we've written to
-		 * another module */
-		(*lib->pTarget->attrs.logWrite)(lib->pTarget->
-			attrs.logWriteHandle, &sectInfo, addr, nBytes);
+	if ((lib != NULL) &&
+	    ((pTarget = lib->pTarget) != NULL) &&
+	    (pTarget->attrs.write != NULL)) {
+		retVal = (*pTarget->attrs.write)(pTarget->attrs.wHandle,
+						 addr, buf, nBytes, memType);
+
+		if (pTarget->attrs.logWrite) {
+			sectInfo.name = info->name;
+			sectInfo.runAddr = info->run_addr;
+			sectInfo.loadAddr = info->load_addr;
+			sectInfo.size = info->size;
+			sectInfo.type = memType;
+			/* Pass the information about what we've written to
+			 * another module */
+			(*pTarget->attrs.logWrite)(
+				pTarget->attrs.logWriteHandle,
+				&sectInfo, addr, nBytes);
+		}
 	}
 	return retVal;
 }