linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Smart <james.smart@broadcom.com>
To: Vasyl Gomonovych <gomonovych@gmail.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: dick.kennedy@broadcom.com, jejb@linux.vnet.ibm.com,
	martin.petersen@oracle.com
Subject: Re: [PATCH] scsi: lpfc: fix kzalloc-simple.cocci warnings
Date: Fri, 3 Nov 2017 08:50:14 -0700	[thread overview]
Message-ID: <0f4c9761-fdab-2311-62ad-f0cd7f432246@broadcom.com> (raw)
In-Reply-To: <1507750961-26945-1-git-send-email-gomonovych@gmail.com>

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 <gomonovych@gmail.com>
> ---
>   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 <james.smart@broadcom.com>

  reply	other threads:[~2017-11-03 15:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 19:42 [PATCH] scsi: lpfc: fix kzalloc-simple.cocci warnings Vasyl Gomonovych
2017-11-03 15:50 ` James Smart [this message]
2017-11-03 16:26 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f4c9761-fdab-2311-62ad-f0cd7f432246@broadcom.com \
    --to=james.smart@broadcom.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=gomonovych@gmail.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).