diff mbox

[3/6] ipr: Fix possible error path oops during initialization

Message ID 201503261623.t2QGNtSX003713@d03av03.boulder.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Brian King March 26, 2015, 4:23 p.m. UTC
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>
---

 drivers/scsi/ipr.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

wenxiong@linux.vnet.ibm.com March 27, 2015, 4:50 p.m. UTC | #1
Reviewed-by: Wen Xiong<wenxiong@linux.vnet.ibm.com>

Thanks,
Wendy

Quoting Brian King <brking@linux.vnet.ibm.com>:

> 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>
> ---
>
>  drivers/scsi/ipr.c |   14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff -puN drivers/scsi/ipr.c~ipr_free_cmd_blks_oops drivers/scsi/ipr.c
> --- linux/drivers/scsi/ipr.c~ipr_free_cmd_blks_oops	2015-03-26  
> 11:14:41.465782868 -0500
> +++ linux-bjking1/drivers/scsi/ipr.c	2015-03-26 11:14:41.471782829 -0500
> @@ -9061,13 +9061,15 @@ static void ipr_free_cmd_blks(struct ipr
>  {
>  	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]);
> +	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;
> +			ioa_cfg->ipr_cmnd_list[i] = NULL;
> +		}
>  	}
>
>  	if (ioa_cfg->ipr_cmd_pool)
> _


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Daniel Kreling March 31, 2015, 1:49 p.m. UTC | #2
** Adding 'Reviewed-by' tag **

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: Daniel Kreling
---

  drivers/scsi/ipr.c |   14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)


=======================================

diff -puN drivers/scsi/ipr.c~ipr_free_cmd_blks_oops drivers/scsi/ipr.c

--- linux/drivers/scsi/ipr.c~ipr_free_cmd_blks_oops    2015-03-26 
11:14:41.465782868 -0500

+++ linux-bjking1/drivers/scsi/ipr.c    2015-03-26 11:14:41.471782829 -0500

@@ -9061,1 +9061,1 @@

static·void·ipr_free_cmd_blks(struct·ipr

  {
      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]);
+    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;
+            ioa_cfg->ipr_cmnd_list[i] = NULL;
+        }
      }

      if (ioa_cfg->ipr_cmd_pool)
diff mbox

Patch

diff -puN drivers/scsi/ipr.c~ipr_free_cmd_blks_oops drivers/scsi/ipr.c
--- linux/drivers/scsi/ipr.c~ipr_free_cmd_blks_oops	2015-03-26 11:14:41.465782868 -0500
+++ linux-bjking1/drivers/scsi/ipr.c	2015-03-26 11:14:41.471782829 -0500
@@ -9061,13 +9061,15 @@  static void ipr_free_cmd_blks(struct ipr
 {
 	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]);
+	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;
+			ioa_cfg->ipr_cmnd_list[i] = NULL;
+		}
 	}
 
 	if (ioa_cfg->ipr_cmd_pool)