Re: [PATCH v2] scsi: fnic: Use vzalloc() instead of vmalloc() and memset(0)

From: kernel test robot
Date: Wed Oct 09 2024 - 00:18:47 EST


Hi Thorsten,

kernel test robot noticed the following build errors:

[auto build test ERROR on jejb-scsi/for-next]
[also build test ERROR on mkp-scsi/for-next linus/master v6.12-rc2 next-20241008]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Thorsten-Blum/scsi-fnic-Use-vzalloc-instead-of-vmalloc-and-memset-0/20241008-175453
base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link: https://lore.kernel.org/r/20241008095152.1831-2-thorsten.blum%40linux.dev
patch subject: [PATCH v2] scsi: fnic: Use vzalloc() instead of vmalloc() and memset(0)
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20241009/202410091146.J4aNjGEe-lkp@xxxxxxxxx/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241009/202410091146.J4aNjGEe-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410091146.J4aNjGEe-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

>> drivers/scsi/fnic/fnic_trace.c:559:27: error: incompatible pointer to integer conversion assigning to 'unsigned long' from 'typeof (vzalloc_noprof(size_mul(((1UL) << 12), fnic_fc_trace_max_pages)))' (aka 'void *') [-Wint-conversion]
559 | fnic_fc_ctlr_trace_buf_p =
| ^
560 | vzalloc(array_size(PAGE_SIZE, fnic_fc_trace_max_pages));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]


vim +559 drivers/scsi/fnic/fnic_trace.c

abb14148c0f850 Hiral Shah 2014-04-18 537
abb14148c0f850 Hiral Shah 2014-04-18 538 /*
abb14148c0f850 Hiral Shah 2014-04-18 539 * fnic_fc_ctlr_trace_buf_init -
abb14148c0f850 Hiral Shah 2014-04-18 540 * Initialize trace buffer to log fnic control frames
abb14148c0f850 Hiral Shah 2014-04-18 541 * Description:
abb14148c0f850 Hiral Shah 2014-04-18 542 * Initialize trace buffer data structure by allocating
abb14148c0f850 Hiral Shah 2014-04-18 543 * required memory for trace data as well as for Indexes.
abb14148c0f850 Hiral Shah 2014-04-18 544 * Frame size is 256 bytes and
abb14148c0f850 Hiral Shah 2014-04-18 545 * memory is allocated for 1024 entries of 256 bytes.
abb14148c0f850 Hiral Shah 2014-04-18 546 * Page_offset(Index) is set to the address of trace entry
abb14148c0f850 Hiral Shah 2014-04-18 547 * and page_offset is initialized by adding frame size
abb14148c0f850 Hiral Shah 2014-04-18 548 * to the previous page_offset entry.
abb14148c0f850 Hiral Shah 2014-04-18 549 */
abb14148c0f850 Hiral Shah 2014-04-18 550
abb14148c0f850 Hiral Shah 2014-04-18 551 int fnic_fc_trace_init(void)
abb14148c0f850 Hiral Shah 2014-04-18 552 {
abb14148c0f850 Hiral Shah 2014-04-18 553 unsigned long fc_trace_buf_head;
abb14148c0f850 Hiral Shah 2014-04-18 554 int err = 0;
abb14148c0f850 Hiral Shah 2014-04-18 555 int i;
abb14148c0f850 Hiral Shah 2014-04-18 556
abb14148c0f850 Hiral Shah 2014-04-18 557 fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/
abb14148c0f850 Hiral Shah 2014-04-18 558 FC_TRC_SIZE_BYTES;
42bc47b35320e0 Kees Cook 2018-06-12 @559 fnic_fc_ctlr_trace_buf_p =
c9ff42f1a76c7b Thorsten Blum 2024-10-08 560 vzalloc(array_size(PAGE_SIZE, fnic_fc_trace_max_pages));
abb14148c0f850 Hiral Shah 2014-04-18 561 if (!fnic_fc_ctlr_trace_buf_p) {
abb14148c0f850 Hiral Shah 2014-04-18 562 pr_err("fnic: Failed to allocate memory for "
abb14148c0f850 Hiral Shah 2014-04-18 563 "FC Control Trace Buf\n");
abb14148c0f850 Hiral Shah 2014-04-18 564 err = -ENOMEM;
abb14148c0f850 Hiral Shah 2014-04-18 565 goto err_fnic_fc_ctlr_trace_buf_init;
abb14148c0f850 Hiral Shah 2014-04-18 566 }
abb14148c0f850 Hiral Shah 2014-04-18 567
abb14148c0f850 Hiral Shah 2014-04-18 568 /* Allocate memory for page offset */
42bc47b35320e0 Kees Cook 2018-06-12 569 fc_trace_entries.page_offset =
c9ff42f1a76c7b Thorsten Blum 2024-10-08 570 vzalloc(array_size(fc_trace_max_entries,
42bc47b35320e0 Kees Cook 2018-06-12 571 sizeof(unsigned long)));
abb14148c0f850 Hiral Shah 2014-04-18 572 if (!fc_trace_entries.page_offset) {
abb14148c0f850 Hiral Shah 2014-04-18 573 pr_err("fnic:Failed to allocate memory for page_offset\n");
abb14148c0f850 Hiral Shah 2014-04-18 574 if (fnic_fc_ctlr_trace_buf_p) {
abb14148c0f850 Hiral Shah 2014-04-18 575 pr_err("fnic: Freeing FC Control Trace Buf\n");
abb14148c0f850 Hiral Shah 2014-04-18 576 vfree((void *)fnic_fc_ctlr_trace_buf_p);
abb14148c0f850 Hiral Shah 2014-04-18 577 fnic_fc_ctlr_trace_buf_p = 0;
abb14148c0f850 Hiral Shah 2014-04-18 578 }
abb14148c0f850 Hiral Shah 2014-04-18 579 err = -ENOMEM;
abb14148c0f850 Hiral Shah 2014-04-18 580 goto err_fnic_fc_ctlr_trace_buf_init;
abb14148c0f850 Hiral Shah 2014-04-18 581 }
abb14148c0f850 Hiral Shah 2014-04-18 582
abb14148c0f850 Hiral Shah 2014-04-18 583 fc_trace_entries.rd_idx = fc_trace_entries.wr_idx = 0;
abb14148c0f850 Hiral Shah 2014-04-18 584 fc_trace_buf_head = fnic_fc_ctlr_trace_buf_p;
abb14148c0f850 Hiral Shah 2014-04-18 585
abb14148c0f850 Hiral Shah 2014-04-18 586 /*
abb14148c0f850 Hiral Shah 2014-04-18 587 * Set up fc_trace_entries.page_offset field with memory location
abb14148c0f850 Hiral Shah 2014-04-18 588 * for every trace entry
abb14148c0f850 Hiral Shah 2014-04-18 589 */
abb14148c0f850 Hiral Shah 2014-04-18 590 for (i = 0; i < fc_trace_max_entries; i++) {
abb14148c0f850 Hiral Shah 2014-04-18 591 fc_trace_entries.page_offset[i] = fc_trace_buf_head;
abb14148c0f850 Hiral Shah 2014-04-18 592 fc_trace_buf_head += FC_TRC_SIZE_BYTES;
abb14148c0f850 Hiral Shah 2014-04-18 593 }
1dbaa379a41934 Greg Kroah-Hartman 2019-01-22 594 fnic_fc_trace_debugfs_init();
abb14148c0f850 Hiral Shah 2014-04-18 595 pr_info("fnic: Successfully Initialized FC_CTLR Trace Buffer\n");
abb14148c0f850 Hiral Shah 2014-04-18 596 return err;
abb14148c0f850 Hiral Shah 2014-04-18 597
abb14148c0f850 Hiral Shah 2014-04-18 598 err_fnic_fc_ctlr_trace_buf_init:
abb14148c0f850 Hiral Shah 2014-04-18 599 return err;
abb14148c0f850 Hiral Shah 2014-04-18 600 }
abb14148c0f850 Hiral Shah 2014-04-18 601

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki