From: Steven Liu on
Hi, Mike Miller,

if kmalloc memory for ld_buff failed,it will free currentsd and
ld_buff once more
so i think this patch may be better

fix code style in drivers/block/cciss_scsi.c

Signed-off-by: Liu Qi <lingjiujianke(a)gmail.com>
---
drivers/block/cciss_scsi.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index e1d0e2c..ad2417f 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -1198,13 +1198,24 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)

c = (ctlr_info_t *) hba[cntl_num];
ld_buff = kzalloc(reportlunsize, GFP_KERNEL);
+ if(ld_buff == NULL){
+ printk(KERN_ERR "cciss: out of memory\n");
+ goto out1;
+ }
+
inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
+ if(inq_buff == NULL){
+ printk(KERN_ERR "cciss: out of memory\n");
+ goto out2;
+ }
+
currentsd = kzalloc(sizeof(*currentsd) *
(CCISS_MAX_SCSI_DEVS_PER_HBA+1), GFP_KERNEL);
- if (ld_buff == NULL || inq_buff == NULL || currentsd == NULL) {
+ if(currentsd == NULL){
printk(KERN_ERR "cciss: out of memory\n");
- goto out;
+ goto out3;
}
+
this_device = &currentsd[CCISS_MAX_SCSI_DEVS_PER_HBA];
if (cciss_scsi_do_report_phys_luns(c, ld_buff, reportlunsize) == 0) {
ch = &ld_buff->LUNListLength[0];
@@ -1289,9 +1300,12 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)

adjust_cciss_scsi_table(cntl_num, hostno, currentsd, ncurrent);
out:
+ kfree(currentsd);
+out3:
kfree(inq_buff);
+out2:
kfree(ld_buff);
- kfree(currentsd);
+out1:
return;
}

--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/