Skip to contentSkip to conversation

Staging: bcm: dereferencing before checking

PATCH New Dan Carpenter 1 participant 1 message Oct 8, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: bcm: dereferencing before checking

I moved the check to see if "Adapter" was null in front of the dereference.

drivers/staging/bcm/CmHost.c +5 -6
index 37187c4..46f3a7d 100644
@@ -1943,15 +1943,14 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter)
 	ULONG ulIndex=0;
 	int Status;
 
+	if (!Adapter) {
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adapter was NULL!!!");
+		return 0;
+	}
+
 	if(Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer)
 		return 1;
 
-	 if(NULL = Adapter)
-	 {
-		 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adapter was NULL!!!");
-		 return 0;
-	 }
-
 	BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Size of Each DSX Buffer(Also size of ServiceFlowParamSI): %zx ",sizeof(stServiceFlowParamSI));
 	BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Reading DSX buffer From Target location %x ",DSX_MESSAGE_EXCHANGE_BUFFER);