lkml.org 
[lkml]   [2010]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH] cciss: fix code style in drivers/block/cciss_scsi.c
From
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@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

\
 
 \ /
  Last update: 2010-05-18 08:01    [W:0.033 / U:25.840 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site