scsi: bfa: Use zeroing allocator rather than allocator/memset

Use vzalloc instead of vmalloc followed by memset 0.

Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Suggested-by: Luis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Acked-by: Anil Gurumurthy <anil.gurumurthy@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Himanshu Jha 2017-12-30 20:58:31 +05:30 committed by Martin K. Petersen
parent 0558312110
commit bde70f3c0e
2 changed files with 3 additions and 8 deletions

View File

@ -610,13 +610,12 @@ bfad_hal_mem_alloc(struct bfad_s *bfad)
/* Iterate through the KVA meminfo queue */ /* Iterate through the KVA meminfo queue */
list_for_each(km_qe, &kva_info->qe) { list_for_each(km_qe, &kva_info->qe) {
kva_elem = (struct bfa_mem_kva_s *) km_qe; kva_elem = (struct bfa_mem_kva_s *) km_qe;
kva_elem->kva = vmalloc(kva_elem->mem_len); kva_elem->kva = vzalloc(kva_elem->mem_len);
if (kva_elem->kva == NULL) { if (kva_elem->kva == NULL) {
bfad_hal_mem_release(bfad); bfad_hal_mem_release(bfad);
rc = BFA_STATUS_ENOMEM; rc = BFA_STATUS_ENOMEM;
goto ext; goto ext;
} }
memset(kva_elem->kva, 0, kva_elem->mem_len);
} }
/* Iterate through the DMA meminfo queue */ /* Iterate through the DMA meminfo queue */

View File

@ -81,7 +81,7 @@ bfad_debugfs_open_fwtrc(struct inode *inode, struct file *file)
fw_debug->buffer_len = sizeof(struct bfa_trc_mod_s); fw_debug->buffer_len = sizeof(struct bfa_trc_mod_s);
fw_debug->debug_buffer = vmalloc(fw_debug->buffer_len); fw_debug->debug_buffer = vzalloc(fw_debug->buffer_len);
if (!fw_debug->debug_buffer) { if (!fw_debug->debug_buffer) {
kfree(fw_debug); kfree(fw_debug);
printk(KERN_INFO "bfad[%d]: Failed to allocate fwtrc buffer\n", printk(KERN_INFO "bfad[%d]: Failed to allocate fwtrc buffer\n",
@ -89,8 +89,6 @@ bfad_debugfs_open_fwtrc(struct inode *inode, struct file *file)
return -ENOMEM; return -ENOMEM;
} }
memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len);
spin_lock_irqsave(&bfad->bfad_lock, flags); spin_lock_irqsave(&bfad->bfad_lock, flags);
rc = bfa_ioc_debug_fwtrc(&bfad->bfa.ioc, rc = bfa_ioc_debug_fwtrc(&bfad->bfa.ioc,
fw_debug->debug_buffer, fw_debug->debug_buffer,
@ -125,7 +123,7 @@ bfad_debugfs_open_fwsave(struct inode *inode, struct file *file)
fw_debug->buffer_len = sizeof(struct bfa_trc_mod_s); fw_debug->buffer_len = sizeof(struct bfa_trc_mod_s);
fw_debug->debug_buffer = vmalloc(fw_debug->buffer_len); fw_debug->debug_buffer = vzalloc(fw_debug->buffer_len);
if (!fw_debug->debug_buffer) { if (!fw_debug->debug_buffer) {
kfree(fw_debug); kfree(fw_debug);
printk(KERN_INFO "bfad[%d]: Failed to allocate fwsave buffer\n", printk(KERN_INFO "bfad[%d]: Failed to allocate fwsave buffer\n",
@ -133,8 +131,6 @@ bfad_debugfs_open_fwsave(struct inode *inode, struct file *file)
return -ENOMEM; return -ENOMEM;
} }
memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len);
spin_lock_irqsave(&bfad->bfad_lock, flags); spin_lock_irqsave(&bfad->bfad_lock, flags);
rc = bfa_ioc_debug_fwsave(&bfad->bfa.ioc, rc = bfa_ioc_debug_fwsave(&bfad->bfa.ioc,
fw_debug->debug_buffer, fw_debug->debug_buffer,