aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJesper Juhl <jesper.juhl@gmail.com>2005-11-07 04:01:26 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 10:54:01 -0500
commitc9475cb0c358ff0dd473544280d92482df491913 (patch)
tree091617d0bdab9273d44139c86af21b7540e6d9b1 /drivers
parent089b1dbbde28f0f641c20beabba28fa89ab4fab9 (diff)
[PATCH] kfree cleanup: drivers/scsi
This is the drivers/scsi/ part of the big kfree cleanup patch. Remove pointless checks for NULL prior to calling kfree() in drivers/scsi/. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Cc: James Bottomley <James.Bottomley@steeleye.com> Acked-by: Kai Makisara <kai.makisara@kolumbus.fi> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/3w-9xxx.c3
-rw-r--r--drivers/scsi/aacraid/commsup.c14
-rw-r--r--drivers/scsi/advansys.c12
-rw-r--r--drivers/scsi/aha1542.c36
-rw-r--r--drivers/scsi/aic7xxx_old.c3
-rw-r--r--drivers/scsi/arm/queue.c3
-rw-r--r--drivers/scsi/dc395x.c3
-rw-r--r--drivers/scsi/dpt_i2o.c27
-rw-r--r--drivers/scsi/eata.c3
-rw-r--r--drivers/scsi/ide-scsi.c10
-rw-r--r--drivers/scsi/ips.c18
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c6
-rw-r--r--drivers/scsi/lpfc/lpfc_mbox.c7
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c7
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c5
-rw-r--r--drivers/scsi/megaraid/megaraid_mm.c11
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c16
-rw-r--r--drivers/scsi/sg.c9
-rw-r--r--drivers/scsi/st.c3
-rw-r--r--drivers/scsi/u14-34f.c9
21 files changed, 73 insertions, 141 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index d06ee65d668d..3ff74f472249 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1017,8 +1017,7 @@ static void twa_free_device_extension(TW_Device_Extension *tw_dev)
1017 tw_dev->generic_buffer_virt[0], 1017 tw_dev->generic_buffer_virt[0],
1018 tw_dev->generic_buffer_phys[0]); 1018 tw_dev->generic_buffer_phys[0]);
1019 1019
1020 if (tw_dev->event_queue[0]) 1020 kfree(tw_dev->event_queue[0]);
1021 kfree(tw_dev->event_queue[0]);
1022} /* End twa_free_device_extension() */ 1021} /* End twa_free_device_extension() */
1023 1022
1024/* This function will free a request id */ 1023/* This function will free a request id */
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index ee9067255930..723c0cea7c04 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1164,7 +1164,7 @@ int aac_command_thread(struct aac_dev * dev)
1164 kfree(hw_fib_pool); 1164 kfree(hw_fib_pool);
1165 hw_fib_pool = NULL; 1165 hw_fib_pool = NULL;
1166 } 1166 }
1167 } else if (hw_fib_pool) { 1167 } else {
1168 kfree(hw_fib_pool); 1168 kfree(hw_fib_pool);
1169 hw_fib_pool = NULL; 1169 hw_fib_pool = NULL;
1170 } 1170 }
@@ -1247,17 +1247,13 @@ int aac_command_thread(struct aac_dev * dev)
1247 hw_fib_p = hw_fib_pool; 1247 hw_fib_p = hw_fib_pool;
1248 fib_p = fib_pool; 1248 fib_p = fib_pool;
1249 while (hw_fib_p < &hw_fib_pool[num]) { 1249 while (hw_fib_p < &hw_fib_pool[num]) {
1250 if (*hw_fib_p) 1250 kfree(*hw_fib_p);
1251 kfree(*hw_fib_p); 1251 kfree(*fib_p);
1252 if (*fib_p)
1253 kfree(*fib_p);
1254 ++fib_p; 1252 ++fib_p;
1255 ++hw_fib_p; 1253 ++hw_fib_p;
1256 } 1254 }
1257 if (hw_fib_pool) 1255 kfree(hw_fib_pool);
1258 kfree(hw_fib_pool); 1256 kfree(fib_pool);
1259 if (fib_pool)
1260 kfree(fib_pool);
1261 } 1257 }
1262 kfree(fib); 1258 kfree(fib);
1263 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags); 1259 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 37ec5411e325..f4cfb8f29620 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -5402,10 +5402,8 @@ advansys_detect(struct scsi_host_template *tpnt)
5402 release_region(shp->io_port, boardp->asc_n_io_port); 5402 release_region(shp->io_port, boardp->asc_n_io_port);
5403 if (ASC_WIDE_BOARD(boardp)) { 5403 if (ASC_WIDE_BOARD(boardp)) {
5404 iounmap(boardp->ioremap_addr); 5404 iounmap(boardp->ioremap_addr);
5405 if (boardp->orig_carrp) { 5405 kfree(boardp->orig_carrp);
5406 kfree(boardp->orig_carrp); 5406 boardp->orig_carrp = NULL;
5407 boardp->orig_carrp = NULL;
5408 }
5409 if (boardp->orig_reqp) { 5407 if (boardp->orig_reqp) {
5410 kfree(boardp->orig_reqp); 5408 kfree(boardp->orig_reqp);
5411 boardp->orig_reqp = boardp->adv_reqp = NULL; 5409 boardp->orig_reqp = boardp->adv_reqp = NULL;
@@ -5457,10 +5455,8 @@ advansys_release(struct Scsi_Host *shp)
5457 adv_sgblk_t *sgp = NULL; 5455 adv_sgblk_t *sgp = NULL;
5458 5456
5459 iounmap(boardp->ioremap_addr); 5457 iounmap(boardp->ioremap_addr);
5460 if (boardp->orig_carrp) { 5458 kfree(boardp->orig_carrp);
5461 kfree(boardp->orig_carrp); 5459 boardp->orig_carrp = NULL;
5462 boardp->orig_carrp = NULL;
5463 }
5464 if (boardp->orig_reqp) { 5460 if (boardp->orig_reqp) {
5465 kfree(boardp->orig_reqp); 5461 kfree(boardp->orig_reqp);
5466 boardp->orig_reqp = boardp->adv_reqp = NULL; 5462 boardp->orig_reqp = boardp->adv_reqp = NULL;
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index adda750412f2..1b1adfb384cb 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -543,10 +543,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id, struct pt
543 return; 543 return;
544 } 544 }
545 my_done = SCtmp->scsi_done; 545 my_done = SCtmp->scsi_done;
546 if (SCtmp->host_scribble) { 546 kfree(SCtmp->host_scribble);
547 kfree(SCtmp->host_scribble); 547 SCtmp->host_scribble = NULL;
548 SCtmp->host_scribble = NULL;
549 }
550 /* Fetch the sense data, and tuck it away, in the required slot. The 548 /* Fetch the sense data, and tuck it away, in the required slot. The
551 Adaptec automatically fetches it, and there is no guarantee that 549 Adaptec automatically fetches it, and there is no guarantee that
552 we will still have it in the cdb when we come back */ 550 we will still have it in the cdb when we come back */
@@ -1432,10 +1430,8 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)
1432 HOSTDATA(SCpnt->host)->SCint[i]->target == SCpnt->target) { 1430 HOSTDATA(SCpnt->host)->SCint[i]->target == SCpnt->target) {
1433 Scsi_Cmnd *SCtmp; 1431 Scsi_Cmnd *SCtmp;
1434 SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; 1432 SCtmp = HOSTDATA(SCpnt->host)->SCint[i];
1435 if (SCtmp->host_scribble) { 1433 kfree(SCtmp->host_scribble);
1436 kfree(SCtmp->host_scribble); 1434 SCtmp->host_scribble = NULL;
1437 SCtmp->host_scribble = NULL;
1438 }
1439 HOSTDATA(SCpnt->host)->SCint[i] = NULL; 1435 HOSTDATA(SCpnt->host)->SCint[i] = NULL;
1440 HOSTDATA(SCpnt->host)->mb[i].status = 0; 1436 HOSTDATA(SCpnt->host)->mb[i].status = 0;
1441 } 1437 }
@@ -1495,10 +1491,8 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)
1495 */ 1491 */
1496 continue; 1492 continue;
1497 } 1493 }
1498 if (SCtmp->host_scribble) { 1494 kfree(SCtmp->host_scribble);
1499 kfree(SCtmp->host_scribble); 1495 SCtmp->host_scribble = NULL;
1500 SCtmp->host_scribble = NULL;
1501 }
1502 HOSTDATA(SCpnt->device->host)->SCint[i] = NULL; 1496 HOSTDATA(SCpnt->device->host)->SCint[i] = NULL;
1503 HOSTDATA(SCpnt->device->host)->mb[i].status = 0; 1497 HOSTDATA(SCpnt->device->host)->mb[i].status = 0;
1504 } 1498 }
@@ -1565,10 +1559,8 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
1565 */ 1559 */
1566 continue; 1560 continue;
1567 } 1561 }
1568 if (SCtmp->host_scribble) { 1562 kfree(SCtmp->host_scribble);
1569 kfree(SCtmp->host_scribble); 1563 SCtmp->host_scribble = NULL;
1570 SCtmp->host_scribble = NULL;
1571 }
1572 HOSTDATA(SCpnt->device->host)->SCint[i] = NULL; 1564 HOSTDATA(SCpnt->device->host)->SCint[i] = NULL;
1573 HOSTDATA(SCpnt->device->host)->mb[i].status = 0; 1565 HOSTDATA(SCpnt->device->host)->mb[i].status = 0;
1574 } 1566 }
@@ -1711,10 +1703,8 @@ static int aha1542_old_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags)
1711 Scsi_Cmnd *SCtmp; 1703 Scsi_Cmnd *SCtmp;
1712 SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; 1704 SCtmp = HOSTDATA(SCpnt->host)->SCint[i];
1713 SCtmp->result = DID_RESET << 16; 1705 SCtmp->result = DID_RESET << 16;
1714 if (SCtmp->host_scribble) { 1706 kfree(SCtmp->host_scribble);
1715 kfree(SCtmp->host_scribble); 1707 SCtmp->host_scribble = NULL;
1716 SCtmp->host_scribble = NULL;
1717 }
1718 printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target); 1708 printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target);
1719 SCtmp->scsi_done(SCpnt); 1709 SCtmp->scsi_done(SCpnt);
1720 1710
@@ -1757,10 +1747,8 @@ fail:
1757 Scsi_Cmnd *SCtmp; 1747 Scsi_Cmnd *SCtmp;
1758 SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; 1748 SCtmp = HOSTDATA(SCpnt->host)->SCint[i];
1759 SCtmp->result = DID_RESET << 16; 1749 SCtmp->result = DID_RESET << 16;
1760 if (SCtmp->host_scribble) { 1750 kfree(SCtmp->host_scribble);
1761 kfree(SCtmp->host_scribble); 1751 SCtmp->host_scribble = NULL;
1762 SCtmp->host_scribble = NULL;
1763 }
1764 printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target); 1752 printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target);
1765 SCtmp->scsi_done(SCpnt); 1753 SCtmp->scsi_done(SCpnt);
1766 1754
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index 52b72d7794f5..880e2d9ffe9b 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -8492,8 +8492,7 @@ aic7xxx_free(struct aic7xxx_host *p)
8492 - scb_dma->dma_offset), 8492 - scb_dma->dma_offset),
8493 scb_dma->dma_address); 8493 scb_dma->dma_address);
8494 } 8494 }
8495 if (p->scb_data->scb_array[i]->kmalloc_ptr != NULL) 8495 kfree(p->scb_data->scb_array[i]->kmalloc_ptr);
8496 kfree(p->scb_data->scb_array[i]->kmalloc_ptr);
8497 p->scb_data->scb_array[i] = NULL; 8496 p->scb_data->scb_array[i] = NULL;
8498 } 8497 }
8499 8498
diff --git a/drivers/scsi/arm/queue.c b/drivers/scsi/arm/queue.c
index e6d159270d29..b10750bb5c09 100644
--- a/drivers/scsi/arm/queue.c
+++ b/drivers/scsi/arm/queue.c
@@ -91,8 +91,7 @@ void queue_free (Queue_t *queue)
91{ 91{
92 if (!list_empty(&queue->head)) 92 if (!list_empty(&queue->head))
93 printk(KERN_WARNING "freeing non-empty queue %p\n", queue); 93 printk(KERN_WARNING "freeing non-empty queue %p\n", queue);
94 if (queue->alloc) 94 kfree(queue->alloc);
95 kfree(queue->alloc);
96} 95}
97 96
98 97
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index c44af5795b10..c8a32cf47d73 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -4270,8 +4270,7 @@ static void adapter_sg_tables_free(struct AdapterCtlBlk *acb)
4270 const unsigned srbs_per_page = PAGE_SIZE/SEGMENTX_LEN; 4270 const unsigned srbs_per_page = PAGE_SIZE/SEGMENTX_LEN;
4271 4271
4272 for (i = 0; i < DC395x_MAX_SRB_CNT; i += srbs_per_page) 4272 for (i = 0; i < DC395x_MAX_SRB_CNT; i += srbs_per_page)
4273 if (acb->srb_array[i].segment_x) 4273 kfree(acb->srb_array[i].segment_x);
4274 kfree(acb->srb_array[i].segment_x);
4275} 4274}
4276 4275
4277 4276
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 46d5571ec55a..c28e3aea1c3c 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1037,18 +1037,10 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1037 if(pHba->msg_addr_virt != pHba->base_addr_virt){ 1037 if(pHba->msg_addr_virt != pHba->base_addr_virt){
1038 iounmap(pHba->msg_addr_virt); 1038 iounmap(pHba->msg_addr_virt);
1039 } 1039 }
1040 if(pHba->hrt) { 1040 kfree(pHba->hrt);
1041 kfree(pHba->hrt); 1041 kfree(pHba->lct);
1042 } 1042 kfree(pHba->status_block);
1043 if(pHba->lct){ 1043 kfree(pHba->reply_pool);
1044 kfree(pHba->lct);
1045 }
1046 if(pHba->status_block) {
1047 kfree(pHba->status_block);
1048 }
1049 if(pHba->reply_pool){
1050 kfree(pHba->reply_pool);
1051 }
1052 1044
1053 for(d = pHba->devices; d ; d = next){ 1045 for(d = pHba->devices; d ; d = next){
1054 next = d->next; 1046 next = d->next;
@@ -2706,14 +2698,12 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
2706 // If the command was successful, fill the fifo with our reply 2698 // If the command was successful, fill the fifo with our reply
2707 // message packets 2699 // message packets
2708 if(*status != 0x04 /*I2O_EXEC_OUTBOUND_INIT_COMPLETE*/) { 2700 if(*status != 0x04 /*I2O_EXEC_OUTBOUND_INIT_COMPLETE*/) {
2709 kfree((void*)status); 2701 kfree(status);
2710 return -2; 2702 return -2;
2711 } 2703 }
2712 kfree((void*)status); 2704 kfree(status);
2713 2705
2714 if(pHba->reply_pool != NULL){ 2706 kfree(pHba->reply_pool);
2715 kfree(pHba->reply_pool);
2716 }
2717 2707
2718 pHba->reply_pool = (u32*)kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); 2708 pHba->reply_pool = (u32*)kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32);
2719 if(!pHba->reply_pool){ 2709 if(!pHba->reply_pool){
@@ -2929,8 +2919,7 @@ static int adpt_i2o_build_sys_table(void)
2929 sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs 2919 sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs
2930 (hba_count) * sizeof(struct i2o_sys_tbl_entry); 2920 (hba_count) * sizeof(struct i2o_sys_tbl_entry);
2931 2921
2932 if(sys_tbl) 2922 kfree(sys_tbl);
2933 kfree(sys_tbl);
2934 2923
2935 sys_tbl = kmalloc(sys_tbl_len, GFP_KERNEL|ADDR32); 2924 sys_tbl = kmalloc(sys_tbl_len, GFP_KERNEL|ADDR32);
2936 if(!sys_tbl) { 2925 if(!sys_tbl) {
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index b45a4c730230..b3f9de8f7595 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -2580,8 +2580,7 @@ static int eata2x_release(struct Scsi_Host *shost)
2580 unsigned int i; 2580 unsigned int i;
2581 2581
2582 for (i = 0; i < shost->can_queue; i++) 2582 for (i = 0; i < shost->can_queue; i++)
2583 if ((&ha->cp[i])->sglist) 2583 kfree((&ha->cp[i])->sglist);
2584 kfree((&ha->cp[i])->sglist);
2585 2584
2586 for (i = 0; i < shost->can_queue; i++) 2585 for (i = 0; i < shost->can_queue; i++)
2587 pci_unmap_single(ha->pdev, ha->cp[i].cp_dma_addr, 2586 pci_unmap_single(ha->pdev, ha->cp[i].cp_dma_addr,
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index f04f3289938d..c888af4a4562 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -331,9 +331,9 @@ static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_co
331 rq = kmalloc (sizeof (struct request), GFP_ATOMIC); 331 rq = kmalloc (sizeof (struct request), GFP_ATOMIC);
332 buf = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); 332 buf = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC);
333 if (pc == NULL || rq == NULL || buf == NULL) { 333 if (pc == NULL || rq == NULL || buf == NULL) {
334 if (pc) kfree(pc); 334 kfree(buf);
335 if (rq) kfree(rq); 335 kfree(rq);
336 if (buf) kfree(buf); 336 kfree(pc);
337 return -ENOMEM; 337 return -ENOMEM;
338 } 338 }
339 memset (pc, 0, sizeof (idescsi_pc_t)); 339 memset (pc, 0, sizeof (idescsi_pc_t));
@@ -949,8 +949,8 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
949 spin_lock_irq(host->host_lock); 949 spin_lock_irq(host->host_lock);
950 return 0; 950 return 0;
951abort: 951abort:
952 if (pc) kfree (pc); 952 kfree (pc);
953 if (rq) kfree (rq); 953 kfree (rq);
954 cmd->result = DID_ERROR << 16; 954 cmd->result = DID_ERROR << 16;
955 done(cmd); 955 done(cmd);
956 return 0; 956 return 0;
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 68e5b2ab27c4..cd9b95db5a7d 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -4517,10 +4517,8 @@ ips_free(ips_ha_t * ha)
4517 ha->enq = NULL; 4517 ha->enq = NULL;
4518 } 4518 }
4519 4519
4520 if (ha->conf) { 4520 kfree(ha->conf);
4521 kfree(ha->conf); 4521 ha->conf = NULL;
4522 ha->conf = NULL;
4523 }
4524 4522
4525 if (ha->adapt) { 4523 if (ha->adapt) {
4526 pci_free_consistent(ha->pcidev, 4524 pci_free_consistent(ha->pcidev,
@@ -4538,15 +4536,11 @@ ips_free(ips_ha_t * ha)
4538 ha->logical_drive_info = NULL; 4536 ha->logical_drive_info = NULL;
4539 } 4537 }
4540 4538
4541 if (ha->nvram) { 4539 kfree(ha->nvram);
4542 kfree(ha->nvram); 4540 ha->nvram = NULL;
4543 ha->nvram = NULL;
4544 }
4545 4541
4546 if (ha->subsys) { 4542 kfree(ha->subsys);
4547 kfree(ha->subsys); 4543 ha->subsys = NULL;
4548 ha->subsys = NULL;
4549 }
4550 4544
4551 if (ha->ioctl_data) { 4545 if (ha->ioctl_data) {
4552 pci_free_consistent(ha->pcidev, ha->ioctl_len, 4546 pci_free_consistent(ha->pcidev, ha->ioctl_len,
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 08a0c00cfc30..bcc29ec126dc 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -127,8 +127,7 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba,
127 if (((pcmd = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) || 127 if (((pcmd = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) ||
128 ((pcmd->virt = lpfc_mbuf_alloc(phba, 128 ((pcmd->virt = lpfc_mbuf_alloc(phba,
129 MEM_PRI, &(pcmd->phys))) == 0)) { 129 MEM_PRI, &(pcmd->phys))) == 0)) {
130 if (pcmd) 130 kfree(pcmd);
131 kfree(pcmd);
132 131
133 spin_lock_irq(phba->host->host_lock); 132 spin_lock_irq(phba->host->host_lock);
134 lpfc_sli_release_iocbq(phba, elsiocb); 133 lpfc_sli_release_iocbq(phba, elsiocb);
@@ -145,8 +144,7 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba,
145 prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, 144 prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
146 &prsp->phys); 145 &prsp->phys);
147 if (prsp == 0 || prsp->virt == 0) { 146 if (prsp == 0 || prsp->virt == 0) {
148 if (prsp) 147 kfree(prsp);
149 kfree(prsp);
150 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys); 148 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
151 kfree(pcmd); 149 kfree(pcmd);
152 spin_lock_irq(phba->host->host_lock); 150 spin_lock_irq(phba->host->host_lock);
@@ -172,8 +170,7 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba,
172 lpfc_mbuf_free(phba, prsp->virt, prsp->phys); 170 lpfc_mbuf_free(phba, prsp->virt, prsp->phys);
173 kfree(pcmd); 171 kfree(pcmd);
174 kfree(prsp); 172 kfree(prsp);
175 if (pbuflist) 173 kfree(pbuflist);
176 kfree(pbuflist);
177 return NULL; 174 return NULL;
178 } 175 }
179 176
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 4e04470321a2..c90723860a04 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -894,8 +894,7 @@ lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt,
894 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, 894 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
895 &mp1->phys); 895 &mp1->phys);
896 if (mp1 == 0 || mp1->virt == 0) { 896 if (mp1 == 0 || mp1->virt == 0) {
897 if (mp1) 897 kfree(mp1);
898 kfree(mp1);
899 spin_lock_irq(phba->host->host_lock); 898 spin_lock_irq(phba->host->host_lock);
900 lpfc_sli_release_iocbq(phba, iocb); 899 lpfc_sli_release_iocbq(phba, iocb);
901 spin_unlock_irq(phba->host->host_lock); 900 spin_unlock_irq(phba->host->host_lock);
@@ -911,8 +910,7 @@ lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt,
911 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, 910 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
912 &mp2->phys); 911 &mp2->phys);
913 if (mp2 == 0 || mp2->virt == 0) { 912 if (mp2 == 0 || mp2->virt == 0) {
914 if (mp2) 913 kfree(mp2);
915 kfree(mp2);
916 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); 914 lpfc_mbuf_free(phba, mp1->virt, mp1->phys);
917 kfree(mp1); 915 kfree(mp1);
918 spin_lock_irq(phba->host->host_lock); 916 spin_lock_irq(phba->host->host_lock);
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
index 31c20cc00609..e3bc8d3f7302 100644
--- a/drivers/scsi/lpfc/lpfc_mbox.c
+++ b/drivers/scsi/lpfc/lpfc_mbox.c
@@ -248,8 +248,7 @@ lpfc_read_sparam(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
248 248
249 if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) || 249 if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) ||
250 ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) { 250 ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) {
251 if (mp) 251 kfree(mp);
252 kfree(mp);
253 mb->mbxCommand = MBX_READ_SPARM64; 252 mb->mbxCommand = MBX_READ_SPARM64;
254 /* READ_SPARAM: no buffers */ 253 /* READ_SPARAM: no buffers */
255 lpfc_printf_log(phba, 254 lpfc_printf_log(phba,
@@ -363,9 +362,7 @@ lpfc_reg_login(struct lpfc_hba * phba,
363 /* Get a buffer to hold NPorts Service Parameters */ 362 /* Get a buffer to hold NPorts Service Parameters */
364 if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == NULL) || 363 if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == NULL) ||
365 ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) { 364 ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) {
366 if (mp) 365 kfree(mp);
367 kfree(mp);
368
369 mb->mbxCommand = MBX_REG_LOGIN64; 366 mb->mbxCommand = MBX_REG_LOGIN64;
370 /* REG_LOGIN: no buffers */ 367 /* REG_LOGIN: no buffers */
371 lpfc_printf_log(phba, 368 lpfc_printf_log(phba,
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 508710001ed6..e2c08c5d83fb 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -2269,11 +2269,8 @@ lpfc_sli_hba_down(struct lpfc_hba * phba)
2269 2269
2270 INIT_LIST_HEAD(&(pring->txq)); 2270 INIT_LIST_HEAD(&(pring->txq));
2271 2271
2272 if (pring->fast_lookup) { 2272 kfree(pring->fast_lookup);
2273 kfree(pring->fast_lookup); 2273 pring->fast_lookup = NULL;
2274 pring->fast_lookup = NULL;
2275 }
2276
2277 } 2274 }
2278 2275
2279 spin_unlock_irqrestore(phba->host->host_lock, flags); 2276 spin_unlock_irqrestore(phba->host->host_lock, flags);
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index c9e743ba09ec..1a3d195a2d36 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -3937,9 +3937,8 @@ megaraid_sysfs_free_resources(adapter_t *adapter)
3937{ 3937{
3938 mraid_device_t *raid_dev = ADAP2RAIDDEV(adapter); 3938 mraid_device_t *raid_dev = ADAP2RAIDDEV(adapter);
3939 3939
3940 if (raid_dev->sysfs_uioc) kfree(raid_dev->sysfs_uioc); 3940 kfree(raid_dev->sysfs_uioc);
3941 3941 kfree(raid_dev->sysfs_mbox64);
3942 if (raid_dev->sysfs_mbox64) kfree(raid_dev->sysfs_mbox64);
3943 3942
3944 if (raid_dev->sysfs_buffer) { 3943 if (raid_dev->sysfs_buffer) {
3945 pci_free_consistent(adapter->pdev, PAGE_SIZE, 3944 pci_free_consistent(adapter->pdev, PAGE_SIZE,
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 37d110e864c4..8f3ce0432295 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -995,17 +995,13 @@ pthru_dma_pool_error:
995 995
996memalloc_error: 996memalloc_error:
997 997
998 if (adapter->kioc_list) 998 kfree(adapter->kioc_list);
999 kfree(adapter->kioc_list); 999 kfree(adapter->mbox_list);
1000
1001 if (adapter->mbox_list)
1002 kfree(adapter->mbox_list);
1003 1000
1004 if (adapter->pthru_dma_pool) 1001 if (adapter->pthru_dma_pool)
1005 pci_pool_destroy(adapter->pthru_dma_pool); 1002 pci_pool_destroy(adapter->pthru_dma_pool);
1006 1003
1007 if (adapter) 1004 kfree(adapter);
1008 kfree(adapter);
1009 1005
1010 return rval; 1006 return rval;
1011} 1007}
@@ -1157,7 +1153,6 @@ mraid_mm_free_adp_resources(mraid_mmadp_t *adp)
1157 } 1153 }
1158 1154
1159 kfree(adp->kioc_list); 1155 kfree(adp->kioc_list);
1160
1161 kfree(adp->mbox_list); 1156 kfree(adp->mbox_list);
1162 1157
1163 pci_pool_destroy(adp->pthru_dma_pool); 1158 pci_pool_destroy(adp->pthru_dma_pool);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 290a6b92616c..72d9090df3df 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1977,8 +1977,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha)
1977 } 1977 }
1978 1978
1979cleanup_allocation: 1979cleanup_allocation:
1980 if (new_fcport) 1980 kfree(new_fcport);
1981 kfree(new_fcport);
1982 1981
1983 if (rval != QLA_SUCCESS) { 1982 if (rval != QLA_SUCCESS) {
1984 DEBUG2(printk("scsi(%ld): Configure local loop error exit: " 1983 DEBUG2(printk("scsi(%ld): Configure local loop error exit: "
@@ -2348,8 +2347,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2348 /* Allocate temporary fcport for any new fcports discovered. */ 2347 /* Allocate temporary fcport for any new fcports discovered. */
2349 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); 2348 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
2350 if (new_fcport == NULL) { 2349 if (new_fcport == NULL) {
2351 if (swl) 2350 kfree(swl);
2352 kfree(swl);
2353 return (QLA_MEMORY_ALLOC_FAILED); 2351 return (QLA_MEMORY_ALLOC_FAILED);
2354 } 2352 }
2355 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); 2353 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
@@ -2485,19 +2483,15 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2485 nxt_d_id.b24 = new_fcport->d_id.b24; 2483 nxt_d_id.b24 = new_fcport->d_id.b24;
2486 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); 2484 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
2487 if (new_fcport == NULL) { 2485 if (new_fcport == NULL) {
2488 if (swl) 2486 kfree(swl);
2489 kfree(swl);
2490 return (QLA_MEMORY_ALLOC_FAILED); 2487 return (QLA_MEMORY_ALLOC_FAILED);
2491 } 2488 }
2492 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); 2489 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
2493 new_fcport->d_id.b24 = nxt_d_id.b24; 2490 new_fcport->d_id.b24 = nxt_d_id.b24;
2494 } 2491 }
2495 2492
2496 if (swl) 2493 kfree(swl);
2497 kfree(swl); 2494 kfree(new_fcport);
2498
2499 if (new_fcport)
2500 kfree(new_fcport);
2501 2495
2502 if (!list_empty(new_fcports)) 2496 if (!list_empty(new_fcports))
2503 ha->device_flags |= DFLG_FABRIC_DEVICES; 2497 ha->device_flags |= DFLG_FABRIC_DEVICES;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 4f30a37db63c..62e3f340cc52 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -476,8 +476,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
476 sg_finish_rem_req(srp); 476 sg_finish_rem_req(srp);
477 retval = count; 477 retval = count;
478free_old_hdr: 478free_old_hdr:
479 if (old_hdr) 479 kfree(old_hdr);
480 kfree(old_hdr);
481 return retval; 480 return retval;
482} 481}
483 482
@@ -1703,10 +1702,8 @@ exit_sg(void)
1703 sg_sysfs_valid = 0; 1702 sg_sysfs_valid = 0;
1704 unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), 1703 unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0),
1705 SG_MAX_DEVS); 1704 SG_MAX_DEVS);
1706 if (sg_dev_arr != NULL) { 1705 kfree((char *)sg_dev_arr);
1707 kfree((char *) sg_dev_arr); 1706 sg_dev_arr = NULL;
1708 sg_dev_arr = NULL;
1709 }
1710 sg_dev_max = 0; 1707 sg_dev_max = 0;
1711} 1708}
1712 1709
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 6b85f84c8397..770c4324f3d5 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4107,8 +4107,7 @@ out_free_tape:
4107 write_unlock(&st_dev_arr_lock); 4107 write_unlock(&st_dev_arr_lock);
4108out_put_disk: 4108out_put_disk:
4109 put_disk(disk); 4109 put_disk(disk);
4110 if (tpnt) 4110 kfree(tpnt);
4111 kfree(tpnt);
4112out_buffer_free: 4111out_buffer_free:
4113 kfree(buffer); 4112 kfree(buffer);
4114out: 4113out:
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
index cfab8f197084..1ce29ba683eb 100644
--- a/drivers/scsi/u14-34f.c
+++ b/drivers/scsi/u14-34f.c
@@ -1953,11 +1953,11 @@ static int u14_34f_release(struct Scsi_Host *shpnt) {
1953 1953
1954 for (j = 0; sh[j] != NULL && sh[j] != shpnt; j++); 1954 for (j = 0; sh[j] != NULL && sh[j] != shpnt; j++);
1955 1955
1956 if (sh[j] == NULL) panic("%s: release, invalid Scsi_Host pointer.\n", 1956 if (sh[j] == NULL)
1957 driver_name); 1957 panic("%s: release, invalid Scsi_Host pointer.\n", driver_name);
1958 1958
1959 for (i = 0; i < sh[j]->can_queue; i++) 1959 for (i = 0; i < sh[j]->can_queue; i++)
1960 if ((&HD(j)->cp[i])->sglist) kfree((&HD(j)->cp[i])->sglist); 1960 kfree((&HD(j)->cp[i])->sglist);
1961 1961
1962 for (i = 0; i < sh[j]->can_queue; i++) 1962 for (i = 0; i < sh[j]->can_queue; i++)
1963 pci_unmap_single(HD(j)->pdev, HD(j)->cp[i].cp_dma_addr, 1963 pci_unmap_single(HD(j)->pdev, HD(j)->cp[i].cp_dma_addr,
@@ -1965,7 +1965,8 @@ static int u14_34f_release(struct Scsi_Host *shpnt) {
1965 1965
1966 free_irq(sh[j]->irq, &sha[j]); 1966 free_irq(sh[j]->irq, &sha[j]);
1967 1967
1968 if (sh[j]->dma_channel != NO_DMA) free_dma(sh[j]->dma_channel); 1968 if (sh[j]->dma_channel != NO_DMA)
1969 free_dma(sh[j]->dma_channel);
1969 1970
1970 release_region(sh[j]->io_port, sh[j]->n_io_port); 1971 release_region(sh[j]->io_port, sh[j]->n_io_port);
1971 scsi_unregister(sh[j]); 1972 scsi_unregister(sh[j]);