Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: fnic: Use vcalloc() instead of vmalloc() and memset(0)

Use vcalloc() instead of vmalloc() followed by memset(0) to simplify the
functions fnic_trace_buf_init() and fnic_fc_trace_init().

Compile-tested only.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20241107104300.1252-1-thorsten.blum@linux.dev
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Thorsten Blum and committed by
Martin K. Petersen
5f8822c4 40384c84

+3 -13
+3 -13
drivers/scsi/fnic/fnic_trace.c
··· 485 485 } 486 486 487 487 fnic_trace_entries.page_offset = 488 - vmalloc(array_size(fnic_max_trace_entries, 489 - sizeof(unsigned long))); 488 + vcalloc(fnic_max_trace_entries, sizeof(unsigned long)); 490 489 if (!fnic_trace_entries.page_offset) { 491 490 printk(KERN_ERR PFX "Failed to allocate memory for" 492 491 " page_offset\n"); ··· 496 497 err = -ENOMEM; 497 498 goto err_fnic_trace_buf_init; 498 499 } 499 - memset((void *)fnic_trace_entries.page_offset, 0, 500 - (fnic_max_trace_entries * sizeof(unsigned long))); 501 500 fnic_trace_entries.wr_idx = fnic_trace_entries.rd_idx = 0; 502 501 fnic_buf_head = fnic_trace_buf_p; 503 502 ··· 556 559 fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/ 557 560 FC_TRC_SIZE_BYTES; 558 561 fnic_fc_ctlr_trace_buf_p = 559 - (unsigned long)vmalloc(array_size(PAGE_SIZE, 560 - fnic_fc_trace_max_pages)); 562 + (unsigned long)vcalloc(fnic_fc_trace_max_pages, PAGE_SIZE); 561 563 if (!fnic_fc_ctlr_trace_buf_p) { 562 564 pr_err("fnic: Failed to allocate memory for " 563 565 "FC Control Trace Buf\n"); ··· 564 568 goto err_fnic_fc_ctlr_trace_buf_init; 565 569 } 566 570 567 - memset((void *)fnic_fc_ctlr_trace_buf_p, 0, 568 - fnic_fc_trace_max_pages * PAGE_SIZE); 569 - 570 571 /* Allocate memory for page offset */ 571 572 fc_trace_entries.page_offset = 572 - vmalloc(array_size(fc_trace_max_entries, 573 - sizeof(unsigned long))); 573 + vcalloc(fc_trace_max_entries, sizeof(unsigned long)); 574 574 if (!fc_trace_entries.page_offset) { 575 575 pr_err("fnic:Failed to allocate memory for page_offset\n"); 576 576 if (fnic_fc_ctlr_trace_buf_p) { ··· 577 585 err = -ENOMEM; 578 586 goto err_fnic_fc_ctlr_trace_buf_init; 579 587 } 580 - memset((void *)fc_trace_entries.page_offset, 0, 581 - (fc_trace_max_entries * sizeof(unsigned long))); 582 588 583 589 fc_trace_entries.rd_idx = fc_trace_entries.wr_idx = 0; 584 590 fc_trace_buf_head = fnic_fc_ctlr_trace_buf_p;