ipr: Fix possible error path oops during initialization
authorBrian King <brking@linux.vnet.ibm.com>
Thu, 26 Mar 2015 16:23:55 +0000 (11:23 -0500)
committerJames Bottomley <JBottomley@Odin.com>
Thu, 9 Apr 2015 20:44:22 +0000 (13:44 -0700)
Fixes a possible oops during adapter initialization in some
memory allocation failure error paths scenarios.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Reviewed-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
Reviewed-by: Daniel Kreling <kreling@linux.vnet.ibm.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
drivers/scsi/ipr.c

index 200110caae175badd47ef7c46eb0f168d7da2440..7b2768fbe0710be50128e9f70538a024ab347933 100644 (file)
@@ -9060,13 +9060,15 @@ static void ipr_free_cmd_blks(struct ipr_ioa_cfg *ioa_cfg)
 {
        int i;
 
-       for (i = 0; i < IPR_NUM_CMD_BLKS; i++) {
-               if (ioa_cfg->ipr_cmnd_list[i])
-                       dma_pool_free(ioa_cfg->ipr_cmd_pool,
-                                     ioa_cfg->ipr_cmnd_list[i],
-                                     ioa_cfg->ipr_cmnd_list_dma[i]);
-
-               ioa_cfg->ipr_cmnd_list[i] = NULL;
+       if (ioa_cfg->ipr_cmnd_list) {
+               for (i = 0; i < IPR_NUM_CMD_BLKS; i++) {
+                       if (ioa_cfg->ipr_cmnd_list[i])
+                               dma_pool_free(ioa_cfg->ipr_cmd_pool,
+                                             ioa_cfg->ipr_cmnd_list[i],
+                                             ioa_cfg->ipr_cmnd_list_dma[i]);
+
+                       ioa_cfg->ipr_cmnd_list[i] = NULL;
+               }
        }
 
        if (ioa_cfg->ipr_cmd_pool)