Received: by 10.223.164.197 with SMTP id h5csp442819wrb; Sat, 4 Nov 2017 14:57:34 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RqZNdC/ehnecC4HX73xW+fWIUnxpyGPQOJw0X7jYvhJy+0u7kQVokjJ8IpwrWfv2Mc4BMi X-Received: by 10.84.215.207 with SMTP id g15mr10660301plj.11.1509832654676; Sat, 04 Nov 2017 14:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509832654; cv=none; d=google.com; s=arc-20160816; b=1DH/baOm0ERe1HOa6lZQINy90dvNWZ/mhpZTba5zc6UlGUuYT6dRyS8kdGcROM3odw rJs/W1sokw8CT5dT/+wkoL0XfaHbOKhUR48jmihmbhTYbc7yS7ZoWmbGfnqwrSst65qO M3VpkbHb/n4nDFdGgeSCWnu0Cr5XM8htPaYN8QVVq/jkTrxaCaeNTVQHvDg9aUn5NPTc 0ddoC7FXTfsjc3C71RZ92Z5UVL8le42EFIOj7goJC0AdgXsHFeZV29AE0ztPRG0yZMcT +x3XHVSwkSFFWsPlpxrBleGzNnb/e0PiBYMWXz6MhXNhMKihliwPp3XJXx18le7qMmRQ lWng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=YXtLCzEC4AC9HAYAksRU9+S1bMAhiOA4wDGqDwjn/Vo=; b=Td3uJpcfdZ4OZhQv7pZCCF1nRTSklXAc+o8JWZsSbajU/Lg5wCmSsikZGnDlbJQPN9 x6GrruZdt7DmflmyutS0vWdMIIJL5/x1Zq47dK+gFWqag5FlFZP8a6qUyvWx09pMfliy SEV3Le9IOihZfby/UPywwxWgm4XF7XN/U/cA3bz+CIB85aHC56ttAXbKv45DdmHkbTQy jTCpdcPbTISYNJo9cl6gucCP1VWcPOfgsnCCo78/jOZXOJxFWL+XYByDJ7jdPxEyn+lQ b0FnT2H1fA+xIjJHDT3qbLmpRvvWqK/N/4K8kCRGC/Eh10ryxs6chN7CX3zMtW+vVpNM AS7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BEuTuhzl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si8720606pgu.231.2017.11.04.14.57.21; Sat, 04 Nov 2017 14:57:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BEuTuhzl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752383AbdKDV4q (ORCPT + 94 others); Sat, 4 Nov 2017 17:56:46 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:47050 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751534AbdKDV4o (ORCPT ); Sat, 4 Nov 2017 17:56:44 -0400 Received: by mail-pf0-f194.google.com with SMTP id p87so4872014pfj.3; Sat, 04 Nov 2017 14:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=YXtLCzEC4AC9HAYAksRU9+S1bMAhiOA4wDGqDwjn/Vo=; b=BEuTuhzlQUseDofA85w8A7Kjmm00osYCDYV9u0SvT1vsBASUXw5RV9YKT/tCU6FAq7 VDp8aYImSdcvCLVA33BaVOp3i31oA/ixHxyYTw7UJoBFXqkMPM2ax5qgtI85i44Dm+64 np0BdFl+MKRvsNYV8NiIZkCyG3PWBcgDqHb7uYMTnSEl2FchnREuABP6+aLNvlRpsr8l ymn1F7uRWxGWOePwp8xSxCyJXSmZ7hkACiuVa/3WVBWYCUZ5u4brF8jgzVR1dDdugdF1 79eBpE8mys/Pxd1KQ46lJqOkm959dDhvG6/ZPFLzJG36oM18AawoEd61EiKISLHTvvn3 v8ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YXtLCzEC4AC9HAYAksRU9+S1bMAhiOA4wDGqDwjn/Vo=; b=YPRQ+cEnpch9+DEeofqkJyYmLe0hp+gj3cAOjeDYbZ3vJBW8G4Dt++E1sLPSbGKQiq wUSAG6qOvGCvKdTXLEI+sZKfIxjQtUelkpiTtiPFSl9vG2WBqO+XzSOKZcvr9fKl9KaM gzaI1k3Fmh6sT02b479C5PAd9V6s0vDA2CqF5Hmq+Qy3ckFJs37lDPzBt0pHuiwZISA4 +jZ95QgrgG3FpwlmoG62jK6+QfkasLWiwkRJjtFb+V0fUKH69ghnfRU8uSjXVR1fckiR EiPurt1AyzOdMOfUhkWgLHaBGt+7PX1wTmgbfaynhJ7pGgmF96ytPLOfBGpMEdp3/C4Y 5xYw== X-Gm-Message-State: AMCzsaU8W2U0v663EHBknju2HOep7mvJo7wLwsVKwKyKKfHx0rCndyBj A3sjoTmf0VaEtArTDY6HeSU= X-Received: by 10.159.198.8 with SMTP id f8mr10746022plo.209.1509832603611; Sat, 04 Nov 2017 14:56:43 -0700 (PDT) Received: from localhost.localdomain ([103.46.195.156]) by smtp.gmail.com with ESMTPSA id d12sm19372632pfl.140.2017.11.04.14.56.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 04 Nov 2017 14:56:42 -0700 (PDT) From: Himanshu Jha To: anil.gurumurthy@qlogic.com Cc: sudarsana.kalluru@qlogic.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, qla2xxx-upstream@qlogic.com, kartilak@cisco.com, sebaddel@cisco.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, mcgrof@kernel.org, Himanshu Jha Subject: [PATCH] scsi: Use vzalloc instead of vmalloc/memset Date: Sun, 5 Nov 2017 03:26:26 +0530 Message-Id: <1509832586-1429-1-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use vzalloc instead of vmalloc/memset to allocate memory filled with 0 value. Done using Coccinelle. Semantic patch used : @@ expression x,a; statement S; @@ - x = vmalloc(a); + x = vzalloc(a); if (x == NULL || ...) S - memset(x, 0, a); Signed-off-by: Himanshu Jha --- drivers/scsi/bfa/bfad.c | 3 +-- drivers/scsi/bfa/bfad_debugfs.c | 8 ++------ drivers/scsi/qla2xxx/qla_bsg.c | 3 +-- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 5 +---- drivers/scsi/scsi_debug.c | 6 ++---- drivers/scsi/snic/snic_trc.c | 3 +-- 6 files changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index 5caf5f3..ab91c59 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c @@ -610,13 +610,12 @@ bfad_hal_mem_alloc(struct bfad_s *bfad) /* Iterate through the KVA meminfo queue */ list_for_each(km_qe, &kva_info->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) { bfad_hal_mem_release(bfad); rc = BFA_STATUS_ENOMEM; goto ext; } - memset(kva_elem->kva, 0, kva_elem->mem_len); } /* Iterate through the DMA meminfo queue */ diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c index 05f5239..349cfe7 100644 --- a/drivers/scsi/bfa/bfad_debugfs.c +++ b/drivers/scsi/bfa/bfad_debugfs.c @@ -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->debug_buffer = vmalloc(fw_debug->buffer_len); + fw_debug->debug_buffer = vzalloc(fw_debug->buffer_len); if (!fw_debug->debug_buffer) { kfree(fw_debug); 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; } - memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len); - spin_lock_irqsave(&bfad->bfad_lock, flags); rc = bfa_ioc_debug_fwtrc(&bfad->bfa.ioc, 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->debug_buffer = vmalloc(fw_debug->buffer_len); + fw_debug->debug_buffer = vzalloc(fw_debug->buffer_len); if (!fw_debug->debug_buffer) { kfree(fw_debug); 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; } - memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len); - spin_lock_irqsave(&bfad->bfad_lock, flags); rc = bfa_ioc_debug_fwsave(&bfad->bfa.ioc, fw_debug->debug_buffer, diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index e3ac707..fdd9059 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -1435,7 +1435,7 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha, ha->optrom_state = QLA_SREADING; } - ha->optrom_buffer = vmalloc(ha->optrom_region_size); + ha->optrom_buffer = vzalloc(ha->optrom_region_size); if (!ha->optrom_buffer) { ql_log(ql_log_warn, vha, 0x7059, "Read: Unable to allocate memory for optrom retrieval " @@ -1445,7 +1445,6 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha, return -ENOMEM; } - memset(ha->optrom_buffer, 0, ha->optrom_region_size); return 0; } diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 3f82ea1..aadfeaa 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -1635,16 +1635,13 @@ static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport *lport) return rc; } - lport->lport_loopid_map = vmalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * - 65536); + lport->lport_loopid_map = vzalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); if (!lport->lport_loopid_map) { pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n", sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); btree_destroy32(&lport->lport_fcport_map); return -ENOMEM; } - memset(lport->lport_loopid_map, 0, sizeof(struct tcm_qla2xxx_fc_loopid) - * 65536); pr_debug("qla2xxx: Allocated lport_loopid_map of %zu bytes\n", sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); return 0; diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index e4f037f..d0e7233 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4500,12 +4500,11 @@ static ssize_t fake_rw_store(struct device_driver *ddp, const char *buf, (unsigned long)sdebug_dev_size_mb * 1048576; - fake_storep = vmalloc(sz); + fake_storep = vzalloc(sz); if (NULL == fake_storep) { pr_err("out of memory, 9\n"); return -ENOMEM; } - memset(fake_storep, 0, sz); } sdebug_fake_rw = n; } @@ -5028,13 +5027,12 @@ static int __init scsi_debug_init(void) } if (sdebug_fake_rw == 0) { - fake_storep = vmalloc(sz); + fake_storep = vzalloc(sz); if (NULL == fake_storep) { pr_err("out of memory, 1\n"); ret = -ENOMEM; goto free_q_arr; } - memset(fake_storep, 0, sz); if (sdebug_num_parts > 0) sdebug_build_parts(fake_storep, sz); } diff --git a/drivers/scsi/snic/snic_trc.c b/drivers/scsi/snic/snic_trc.c index f00ebf4..dd47f50 100644 --- a/drivers/scsi/snic/snic_trc.c +++ b/drivers/scsi/snic/snic_trc.c @@ -126,7 +126,7 @@ snic_trc_init(void) int tbuf_sz = 0, ret; tbuf_sz = (snic_trace_max_pages * PAGE_SIZE); - tbuf = vmalloc(tbuf_sz); + tbuf = vzalloc(tbuf_sz); if (!tbuf) { SNIC_ERR("Failed to Allocate Trace Buffer Size. %d\n", tbuf_sz); SNIC_ERR("Trace Facility not enabled.\n"); @@ -135,7 +135,6 @@ snic_trc_init(void) return ret; } - memset(tbuf, 0, tbuf_sz); trc->buf = (struct snic_trc_data *) tbuf; spin_lock_init(&trc->lock); -- 2.7.4 From 1583394110496877728@xxx Tue Nov 07 08:11:35 +0000 2017 X-GM-THRID: 1583375844872880825 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread