drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c:532:62-63: WARNING comparing pointer to 0

From: kernel test robot
Date: Thu Dec 14 2023 - 18:48:57 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c7402612e2e61b76177f22e6e7f705adcbecc6fe
commit: 5911d02cac70d7fb52009fbd37423e63f8f6f9bc drm/amd/display: Change the DMCUB mailbox memory location from FB to inbox
date: 4 weeks ago
config: x86_64-randconfig-104-20231214 (https://download.01.org/0day-ci/archive/20231215/202312150759.RDeuSwNA-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231215/202312150759.RDeuSwNA-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/202312150759.RDeuSwNA-lkp@xxxxxxxxx/

cocci warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c:532:62-63: WARNING comparing pointer to 0

vim +532 drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c

505
506 enum dmub_status dmub_srv_calc_mem_info(struct dmub_srv *dmub,
507 const struct dmub_srv_memory_params *params,
508 struct dmub_srv_fb_info *out)
509 {
510 uint8_t *cpu_base;
511 uint64_t gpu_base;
512 uint32_t i;
513
514 if (!dmub->sw_init)
515 return DMUB_STATUS_INVALID;
516
517 memset(out, 0, sizeof(*out));
518
519 if (params->region_info->num_regions != DMUB_NUM_WINDOWS)
520 return DMUB_STATUS_INVALID;
521
522 cpu_base = (uint8_t *)params->cpu_fb_addr;
523 gpu_base = params->gpu_fb_addr;
524
525 for (i = 0; i < DMUB_NUM_WINDOWS; ++i) {
526 const struct dmub_region *reg =
527 &params->region_info->regions[i];
528
529 out->fb[i].cpu_addr = cpu_base + reg->base;
530 out->fb[i].gpu_addr = gpu_base + reg->base;
531
> 532 if (i == DMUB_WINDOW_4_MAILBOX && params->cpu_inbox_addr != 0) {
533 out->fb[i].cpu_addr = (uint8_t *)params->cpu_inbox_addr + reg->base;
534 out->fb[i].gpu_addr = params->gpu_inbox_addr + reg->base;
535 }
536
537 out->fb[i].size = reg->top - reg->base;
538 }
539
540 out->num_fb = DMUB_NUM_WINDOWS;
541
542 return DMUB_STATUS_OK;
543 }
544

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