From: Brian King Date: Thu, 26 Mar 2015 16:23:55 +0000 (-0500) Subject: ipr: Fix possible error path oops during initialization X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a65e8f128eca1efafeb16039650ae36b25cfd0dc;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git ipr: Fix possible error path oops during initialization Fixes a possible oops during adapter initialization in some memory allocation failure error paths scenarios. Reported-by: Dan Carpenter Signed-off-by: Brian King Reviewed-by: Wen Xiong Reviewed-by: Daniel Kreling Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 200110caae17..7b2768fbe071 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -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)