From patchwork Wed Oct 11 19:42:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vasyl Gomonovych X-Patchwork-Id: 10000421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1BBA060216 for ; Wed, 11 Oct 2017 19:43:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0870028B3D for ; Wed, 11 Oct 2017 19:43:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F15B328B54; Wed, 11 Oct 2017 19:43:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEA0928B3D for ; Wed, 11 Oct 2017 19:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752563AbdJKTmx (ORCPT ); Wed, 11 Oct 2017 15:42:53 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36900 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752254AbdJKTmw (ORCPT ); Wed, 11 Oct 2017 15:42:52 -0400 Received: by mail-lf0-f66.google.com with SMTP id 90so1068471lfs.4; Wed, 11 Oct 2017 12:42:51 -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=OGAGAH8IcjnMAyWaYOhiHZmJdQiU0RgJ98aNXIumOJE=; b=lmbsIqxnauwEQbf7zHebGqsWQzBRe/x/Fo2tQlKxDxWTk61xZIZm8HqG673eCa+Zn/ ESRP25vuSO7tKQWIeq+/GQN8usE3nCjPLt8GgQuU7EsVX7Ewhr1OXBl071GVDrZqiNE+ QYSO4uBKIOnc+l4p9mRh55HS8Z5qgorRQ4pEwzwR9RxdBEihSxHvyKOkQ4KjntfhSkOO PM2Zok7txEbhBxjA4PVJLawW6vsXK578nU0nEAmaGTlo2wd2T76nL9eMTKZMkFevq5wU woc21rY/09jxekJGeYLuKVwa5mHwWD9pxhiAOextSj+Qtcnrms8pWChuKGHj1PSx4OLI lexA== 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=OGAGAH8IcjnMAyWaYOhiHZmJdQiU0RgJ98aNXIumOJE=; b=k9B0zqaFUfmhwSMMvuxeup2NnlHR7e6ns2xUtl/RwfuDQZSkAaZu9Bm0ZHaZmignGh nPp9JMnX3PyJswDE+sRFoOBnZRzKEG4QEOs71hHxjH9woWH1ztM5sGqNLk6z6HieU3JL 4hwP/muMqKjYPtNFQaVFZLrt8TDeDdwDxaMB4ceTL9gOA5x9fOqKI2ucI7c2YtRKBleW WUWFwH6lQxi1Tv/ie64sbd9I6Wou/vt+M/GJ+WrcBvEXQxWQnPRb5Qd/+ib99vjmaOTi fBgZlMaRvwxb1Pal9WxwV9mDfXU0AucT8GdDbbDyQSXjpaLMmNMjHtXw9lCVQM9Z9Dn8 cC2Q== X-Gm-Message-State: AMCzsaXJZadqm/XRpHQ4n8/kKn/O9aTu9WvlU8ZtHveOKclMQHuz23pv T9BDx2wwHUPRxBYcNaaNXhzWGzGH X-Google-Smtp-Source: AOwi7QCAtVlZVjbrZo6m+9A5+Idvz1exRgOsWRgrwFjXrOHjxAcnlimO9GwaiKFqwmYjtJxPk5Jmfw== X-Received: by 10.46.89.199 with SMTP id g68mr50562ljf.12.1507750970634; Wed, 11 Oct 2017 12:42:50 -0700 (PDT) Received: from localhost.localdomain ([195.254.138.66]) by smtp.gmail.com with ESMTPSA id f196sm2364760lff.83.2017.10.11.12.42.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Oct 2017 12:42:50 -0700 (PDT) From: Vasyl Gomonovych To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: james.smart@broadcom.com, dick.kennedy@broadcom.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, gomonovych@gmail.com Subject: [PATCH] scsi: lpfc: fix kzalloc-simple.cocci warnings Date: Wed, 11 Oct 2017 21:42:41 +0200 Message-Id: <1507750961-26945-1-git-send-email-gomonovych@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by:  James Smart --- 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;