Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Use dma_zalloc_coherent and vzalloc instead of dma_alloc_coherent and
vmalloc respectively, 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: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Himanshu Jha and committed by
Martin K. Petersen
05583121 d103adb3

+6 -13
+2 -3
drivers/scsi/qla2xxx/qla_attr.c
··· 1843 1843 if (qla2x00_reset_active(vha)) 1844 1844 goto done; 1845 1845 1846 - stats = dma_alloc_coherent(&ha->pdev->dev, 1847 - sizeof(*stats), &stats_dma, GFP_KERNEL); 1846 + stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats), 1847 + &stats_dma, GFP_KERNEL); 1848 1848 if (!stats) { 1849 1849 ql_log(ql_log_warn, vha, 0x707d, 1850 1850 "Failed to allocate memory for stats.\n"); 1851 1851 goto done; 1852 1852 } 1853 - memset(stats, 0, sizeof(*stats)); 1854 1853 1855 1854 rval = QLA_FUNCTION_FAILED; 1856 1855 if (IS_FWI2_CAPABLE(ha)) {
+3 -6
drivers/scsi/qla2xxx/qla_bsg.c
··· 1435 1435 ha->optrom_state = QLA_SREADING; 1436 1436 } 1437 1437 1438 - ha->optrom_buffer = vmalloc(ha->optrom_region_size); 1438 + ha->optrom_buffer = vzalloc(ha->optrom_region_size); 1439 1439 if (!ha->optrom_buffer) { 1440 1440 ql_log(ql_log_warn, vha, 0x7059, 1441 1441 "Read: Unable to allocate memory for optrom retrieval " ··· 1445 1445 return -ENOMEM; 1446 1446 } 1447 1447 1448 - memset(ha->optrom_buffer, 0, ha->optrom_region_size); 1449 1448 return 0; 1450 1449 } 1451 1450 ··· 2313 2314 if (!IS_FWI2_CAPABLE(ha)) 2314 2315 return -EPERM; 2315 2316 2316 - stats = dma_alloc_coherent(&ha->pdev->dev, 2317 - sizeof(*stats), &stats_dma, GFP_KERNEL); 2317 + stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats), 2318 + &stats_dma, GFP_KERNEL); 2318 2319 if (!stats) { 2319 2320 ql_log(ql_log_warn, vha, 0x70e2, 2320 2321 "Failed to allocate memory for stats.\n"); 2321 2322 return -ENOMEM; 2322 2323 } 2323 - 2324 - memset(stats, 0, sizeof(*stats)); 2325 2324 2326 2325 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, options); 2327 2326
+1 -4
drivers/scsi/qla2xxx/tcm_qla2xxx.c
··· 1635 1635 return rc; 1636 1636 } 1637 1637 1638 - lport->lport_loopid_map = vmalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * 1639 - 65536); 1638 + lport->lport_loopid_map = vzalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); 1640 1639 if (!lport->lport_loopid_map) { 1641 1640 pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n", 1642 1641 sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); 1643 1642 btree_destroy32(&lport->lport_fcport_map); 1644 1643 return -ENOMEM; 1645 1644 } 1646 - memset(lport->lport_loopid_map, 0, sizeof(struct tcm_qla2xxx_fc_loopid) 1647 - * 65536); 1648 1645 pr_debug("qla2xxx: Allocated lport_loopid_map of %zu bytes\n", 1649 1646 sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); 1650 1647 return 0;