Skip to contentSkip to conversation

Clean up failure path in DAC960

PATCH New Dave Jones 1 participant 1 message Sep 1, 2004 Block layer

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

PATCH 1/1 Clean up failure path in DAC960

1. If the ScatterGatherPool allocation fails, its pointless trying to allocate a RequestSensePool.
2. Free up the ScatterGatherPool if the RequestSensePool allocation fails.

Spotted with the source checker from Coverity.com.

drivers/block/DAC960.c +6 -1
diff -urpN --exclude-from=/home/davej/.exclude bk-linus/drivers/block/DAC960.c linux-2.6/drivers/block/DAC960.c
@@ -288,12 +288,17 @@ static boolean DAC960_CreateAuxiliaryStr
 		Controller->PCIDevice,
 	DAC960_V2_ScatterGatherLimit * sizeof(DAC960_V2_ScatterGatherSegment_T),
 	sizeof(DAC960_V2_ScatterGatherSegment_T), 0);
+      if (ScatterGatherPool == NULL)
+	    return DAC960_Failure(Controller,
+			"AUXILIARY STRUCTURE CREATION (SG)");
       RequestSensePool = pci_pool_create("DAC960_V2_RequestSense",
 		Controller->PCIDevice, sizeof(DAC960_SCSI_RequestSense_T),
 		sizeof(int), 0);
-      if (ScatterGatherPool == NULL || RequestSensePool == NULL)
+      if (RequestSensePool == NULL) {
+	    pci_pool_destroy(ScatterGatherPool);
 	    return DAC960_Failure(Controller,
 			"AUXILIARY STRUCTURE CREATION (SG)");
+      }
       Controller->ScatterGatherPool = ScatterGatherPool;
       Controller->V2.RequestSensePool = RequestSensePool;
     }