From d998729e166273a4dce034fcd523a53f3ddfef0f Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 2 Sep 2004 00:37:17 -0700 Subject: [PATCH] [PATCH] 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. Signed-off-by: Dave Jones Signed-off-by: Linus Torvalds --- drivers/block/DAC960.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 56b9ce97c9b7a..5b908e64aa229 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -288,12 +288,17 @@ static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller) 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; } -- 2.53.0