linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: wenxiong@linux.vnet.ibm.com
To: James.Bottomley@HansenPartnership.com
Cc: linux-scsi@vger.kernel.org, brking@linux.vnet.ibm.com,
	klebers@linux.vnet.ibm.com,
	Wen Xiong <wenxiong@linux.vnet.ibm.com>
Subject: [PATCH 2/8] V2 ipr: Handler ID memory allocation failure
Date: Fri, 11 Jan 2013 17:43:48 -0600	[thread overview]
Message-ID: <20130111234530.076930245@linux.vnet.ibm.com> (raw)
In-Reply-To: 20130111234346.012076652@linux.vnet.ibm.com

[-- Attachment #1: fix_mem_alloc_fail --]
[-- Type: text/plain, Size: 1244 bytes --]

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

Add code to handle memory allocation failures at module load time.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
---

 drivers/scsi/ipr.c |    7 +++++++
 1 file changed, 7 insertions(+)

Index: b/drivers/scsi/ipr.c
===================================================================
--- a/drivers/scsi/ipr.c	2013-01-11 13:30:56.053727535 -0600
+++ b/drivers/scsi/ipr.c	2013-01-11 13:31:21.703731278 -0600
@@ -8516,6 +8516,10 @@ static int ipr_alloc_mem(struct ipr_ioa_
 					     BITS_TO_LONGS(ioa_cfg->max_devs_supported), GFP_KERNEL);
 		ioa_cfg->vset_ids = kzalloc(sizeof(unsigned long) *
 					    BITS_TO_LONGS(ioa_cfg->max_devs_supported), GFP_KERNEL);
+
+		if (!ioa_cfg->target_ids || !ioa_cfg->array_ids
+			|| !ioa_cfg->vset_ids)
+			goto out_free_res_entries;
 	}
 
 	for (i = 0; i < ioa_cfg->max_devs_supported; i++) {
@@ -8591,6 +8595,9 @@ out_free_vpd_cbs:
 			    ioa_cfg->vpd_cbs, ioa_cfg->vpd_cbs_dma);
 out_free_res_entries:
 	kfree(ioa_cfg->res_entries);
+	kfree(ioa_cfg->target_ids);
+	kfree(ioa_cfg->array_ids);
+	kfree(ioa_cfg->vset_ids);
 	goto out;
 }
 

-- 

  parent reply	other threads:[~2013-01-11 23:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 23:43 [PATCH 0/8] V2 Add support for new IBM SAS controllers wenxiong
2013-01-11 23:43 ` [PATCH 1/8] V2 ipr: Add sereral new CCIN definitions for new adapters support wenxiong
2013-01-11 23:43 ` wenxiong [this message]
2013-01-11 23:43 ` [PATCH 3/8] V2 ipr: Resource path error logging cleanup wenxiong
2013-01-11 23:43 ` [PATCH 4/8] V2 ipr: Add support for MSI-X and distributed completion wenxiong
2013-01-11 23:43 ` [PATCH 5/8] V2 ipr: Reduce lock contention wenxiong
2013-01-11 23:43 ` [PATCH 6/8] V2 ipr: Implement block iopoll wenxiong
2013-01-12  0:35   ` Asias He
2013-01-14 15:27     ` wenxiong
2013-01-11 23:43 ` [PATCH 7/8] V2 ipr: Driver version 2.6.0 wenxiong
2013-01-11 23:43 ` [PATCH 8/8] V2 ipr: Fix sparse error in ipr driver wenxiong
2013-01-14 22:13 ` [PATCH 0/8] V2 Add support for new IBM SAS controllers Brian King
2013-02-04  7:00 ` Mike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130111234530.076930245@linux.vnet.ibm.com \
    --to=wenxiong@linux.vnet.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=klebers@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).