Received: by 10.223.164.221 with SMTP id h29csp269551wrb; Fri, 3 Nov 2017 08:52:43 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T1TrypyBF/vrpG64FvwksVrKlg+wKoslMa/ztyXzGPh5BdAK5ko9SDBr07nq6nTqpIhe9Y X-Received: by 10.159.214.140 with SMTP id n12mr6998894plp.4.1509724363570; Fri, 03 Nov 2017 08:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509724363; cv=none; d=google.com; s=arc-20160816; b=i8Kpirl/EdpN1AZCs7ieZsQ+c2ytVOncvp+SUggHK18V4BN3PQXYmD+BvweDhWXHcA 6ydd4Q6UHG+khHk6wyv333Xac+KCrbl+gkJBBjYR9AR8zq3RfMzfOdpCKOdCmYY2erOG /CBr0tXh21ESNoPc2RRo1hzosOFW7UdswgHjjhSaB0F1d5LVweRVJ56GeHgAd6oHRbFl /cGF8sginn+Y+VeyHJfP4FY0tmsXzC7yf/8m91Eq+kE+/IYhTLFhDYWJCuY4VG8Ze/B2 QpjXlAVFEbzf5QjvVSNS6cNpghEmFDU5XDdVT6oEgU4cEWKOC19EL0pIssN+ZUcpNmQN //gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=or8Xh+PRvY0y1wU5eRKPyWh/0Sx8R3OqJZiuQQnUhBU=; b=XH2rrWOmz8LC5WZoLwjxHQlZNi8ccRgAduSQOftcVs/vslVOW9R3BxL3kb5G9s5waP aG7fdoFRwEHVV/Mz+1USEj04vETLGNaRE/DiWhmVryWbo2HAC56wId6zEvzeBztVvaIO w5FEetSpet2khyjRwXvgHc85hGFVTwf40v69HOjM1+WY34P6xUk+5k7CF5QFEsOYpsBN bZGpfSdTPopdyWnPbarW2T2+knI7YRy1kuY1Mqda/74mWJ1cktVTOvMQJCcXWRwFstu4 tNpVZyWGZYlQ0hQW65eNLcm/2r2DjLnkG7d2NrgjCtiGInH1G31X7bAuezNQD1SB/KIT xF6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=GE6hvTpD; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15si5050069plk.488.2017.11.03.08.52.29; Fri, 03 Nov 2017 08:52:43 -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=@broadcom.com header.s=google header.b=GE6hvTpD; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755983AbdKCPuZ (ORCPT + 95 others); Fri, 3 Nov 2017 11:50:25 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:46377 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753880AbdKCPuW (ORCPT ); Fri, 3 Nov 2017 11:50:22 -0400 Received: by mail-qt0-f196.google.com with SMTP id 1so3761069qtn.3 for ; Fri, 03 Nov 2017 08:50:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=or8Xh+PRvY0y1wU5eRKPyWh/0Sx8R3OqJZiuQQnUhBU=; b=GE6hvTpDddILKaOA3i9RR8k35ddhBeVm7v5sFPgDroROn0QEip8Cr+gNpP9fsY29FJ GXTP2IAdu2tlfbuv9EC4O5+33zecfR3HGfRv8m2Au261ugEskbR8mEgetafnE5UvnTsv cJduclKT6AYas1YGTXnKSS7zGOTwgfYJT1BYo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=or8Xh+PRvY0y1wU5eRKPyWh/0Sx8R3OqJZiuQQnUhBU=; b=WVUIDURc6bySHDrSD99qESMAWK2Sq50KikUc8iVRqOXWhAr7wa/dExX8Ah4aGaVnUu rUCtY7u1cWgXWewuiv6clxsW9XC0nPGq0o7HADHbVeFIm76U/dOrzAx6qbpZNR2ps9pC ldR16Q4Nk8/yoB5sQLp1fLo/DZQkaUitetUU3XSuTa8RqA5jymQ0hIDGgH/dTRhiqGXv knKDQ0PFFQRQQ6UGFTRlYWLmdz3dZqxf2FpYk1nDs8YLE30w0wlS0Hvn8moyBuMYTD7t g0n1hiDGJyzkDKGC0bHVn/Qosk9Okb8m1ki5h6G1Dli4E02HWZaQGdb3PJLuccLBank6 iLlw== X-Gm-Message-State: AMCzsaX5wXZywA6ti6jpSt8eRL5NMXNXldwIbFUAvXjrUKnDkneZo9Jt FMZ7X3LlQim8kUuqcphETjMUpw== X-Received: by 10.237.63.17 with SMTP id p17mr11092623qtf.235.1509724216882; Fri, 03 Nov 2017 08:50:16 -0700 (PDT) Received: from [10.112.72.176] ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id a26sm4218556qta.50.2017.11.03.08.50.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 08:50:15 -0700 (PDT) Subject: Re: [PATCH] scsi: lpfc: fix kzalloc-simple.cocci warnings To: Vasyl Gomonovych , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dick.kennedy@broadcom.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com References: <1507750961-26945-1-git-send-email-gomonovych@gmail.com> From: James Smart Message-ID: <0f4c9761-fdab-2311-62ad-f0cd7f432246@broadcom.com> Date: Fri, 3 Nov 2017 08:50:14 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1507750961-26945-1-git-send-email-gomonovych@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/11/2017 12:42 PM, Vasyl Gomonovych wrote: > drivers/scsi/lpfc/lpfc_debugfs.c:5460:22-29: WARNING: kzalloc should be used for phba -> nvmeio_trc, instead of kmalloc/memset > drivers/scsi/lpfc/lpfc_debugfs.c:2230:20-27: WARNING: kzalloc should be used for phba -> nvmeio_trc, instead of kmalloc/memset > > Use kzalloc rather than kmalloc followed by memset with 0 > > Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci > > Signed-off-by: Vasyl Gomonovych > --- > drivers/scsi/lpfc/lpfc_debugfs.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c > index d50c481..2bf5ad3 100644 > --- a/drivers/scsi/lpfc/lpfc_debugfs.c > +++ b/drivers/scsi/lpfc/lpfc_debugfs.c > @@ -2227,7 +2227,7 @@ > kfree(phba->nvmeio_trc); > > /* Allocate new trace buffer and initialize */ > - phba->nvmeio_trc = kmalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) * > + phba->nvmeio_trc = kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) * > sz), GFP_KERNEL); > if (!phba->nvmeio_trc) { > lpfc_printf_log(phba, KERN_ERR, LOG_INIT, > @@ -2235,8 +2235,6 @@ > "nvmeio_trc buffer\n"); > return -ENOMEM; > } > - memset(phba->nvmeio_trc, 0, > - (sizeof(struct lpfc_debugfs_nvmeio_trc) * sz)); > atomic_set(&phba->nvmeio_trc_cnt, 0); > phba->nvmeio_trc_on = 0; > phba->nvmeio_trc_output_idx = 0; > @@ -5457,7 +5455,7 @@ static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes, > phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc; > > /* Allocate trace buffer and initialize */ > - phba->nvmeio_trc = kmalloc( > + phba->nvmeio_trc = kzalloc( > (sizeof(struct lpfc_debugfs_nvmeio_trc) * > phba->nvmeio_trc_size), GFP_KERNEL); > > @@ -5467,9 +5465,6 @@ static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes, > "nvmeio_trc buffer\n"); > goto nvmeio_off; > } > - memset(phba->nvmeio_trc, 0, > - (sizeof(struct lpfc_debugfs_nvmeio_trc) * > - phba->nvmeio_trc_size)); > phba->nvmeio_trc_on = 1; > phba->nvmeio_trc_output_idx = 0; > phba->nvmeio_trc = NULL; looks good. Signed-off-by:  James Smart From 1580991524601318932@xxx Wed Oct 11 19:43:31 +0000 2017 X-GM-THRID: 1580991524601318932 X-Gmail-Labels: Inbox,Category Forums