diff options
author | Vasyl Gomonovych <gomonovych@gmail.com> | 2017-10-11 15:42:41 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-11-03 12:26:09 -0400 |
commit | 1c356ec5e932c8d4c83d9782ab3c4164b6471d5d (patch) | |
tree | b811b4e5c017aacda748f022856917fc132eb218 | |
parent | 62d2f77438873d366807e0db81bd05a8bab566d8 (diff) |
scsi: lpfc: fix kzalloc-simple.cocci warnings
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>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/lpfc/lpfc_debugfs.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index d50c481ec41c..2bf5ad3b1512 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c | |||
@@ -2227,7 +2227,7 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf, | |||
2227 | kfree(phba->nvmeio_trc); | 2227 | kfree(phba->nvmeio_trc); |
2228 | 2228 | ||
2229 | /* Allocate new trace buffer and initialize */ | 2229 | /* Allocate new trace buffer and initialize */ |
2230 | phba->nvmeio_trc = kmalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) * | 2230 | phba->nvmeio_trc = kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) * |
2231 | sz), GFP_KERNEL); | 2231 | sz), GFP_KERNEL); |
2232 | if (!phba->nvmeio_trc) { | 2232 | if (!phba->nvmeio_trc) { |
2233 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 2233 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
@@ -2235,8 +2235,6 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf, | |||
2235 | "nvmeio_trc buffer\n"); | 2235 | "nvmeio_trc buffer\n"); |
2236 | return -ENOMEM; | 2236 | return -ENOMEM; |
2237 | } | 2237 | } |
2238 | memset(phba->nvmeio_trc, 0, | ||
2239 | (sizeof(struct lpfc_debugfs_nvmeio_trc) * sz)); | ||
2240 | atomic_set(&phba->nvmeio_trc_cnt, 0); | 2238 | atomic_set(&phba->nvmeio_trc_cnt, 0); |
2241 | phba->nvmeio_trc_on = 0; | 2239 | phba->nvmeio_trc_on = 0; |
2242 | phba->nvmeio_trc_output_idx = 0; | 2240 | phba->nvmeio_trc_output_idx = 0; |
@@ -5457,7 +5455,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) | |||
5457 | phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc; | 5455 | phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc; |
5458 | 5456 | ||
5459 | /* Allocate trace buffer and initialize */ | 5457 | /* Allocate trace buffer and initialize */ |
5460 | phba->nvmeio_trc = kmalloc( | 5458 | phba->nvmeio_trc = kzalloc( |
5461 | (sizeof(struct lpfc_debugfs_nvmeio_trc) * | 5459 | (sizeof(struct lpfc_debugfs_nvmeio_trc) * |
5462 | phba->nvmeio_trc_size), GFP_KERNEL); | 5460 | phba->nvmeio_trc_size), GFP_KERNEL); |
5463 | 5461 | ||
@@ -5467,9 +5465,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) | |||
5467 | "nvmeio_trc buffer\n"); | 5465 | "nvmeio_trc buffer\n"); |
5468 | goto nvmeio_off; | 5466 | goto nvmeio_off; |
5469 | } | 5467 | } |
5470 | memset(phba->nvmeio_trc, 0, | ||
5471 | (sizeof(struct lpfc_debugfs_nvmeio_trc) * | ||
5472 | phba->nvmeio_trc_size)); | ||
5473 | phba->nvmeio_trc_on = 1; | 5468 | phba->nvmeio_trc_on = 1; |
5474 | phba->nvmeio_trc_output_idx = 0; | 5469 | phba->nvmeio_trc_output_idx = 0; |
5475 | phba->nvmeio_trc = NULL; | 5470 | phba->nvmeio_trc = NULL; |