tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git  
master
head:   4525c8781ec0701ce824e8bd379ae1b129e26568
commit: d0e63b343e575e8b74c185565b0d79a93494bcaa drm/amdkfd: Use kvmalloc 
instead of kmalloc for VCRAT
compiler: powerpc64le-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

   In file included from drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:
>> drivers/gpu/drm/amd/amdkfd/kfd_crat.c:801:9: warning: Either the condition 
>> '!pcrat_image' is redundant or there is possible null pointer dereference: 
>> pcrat_image. [nullPointerRedundantCheck]
    memcpy(pcrat_image, crat_table, crat_table->length);
           ^
   drivers/gpu/drm/amd/amdkfd/kfd_crat.c:802:6: note: Assuming that condition 
'!pcrat_image' is not redundant
    if (!pcrat_image)
        ^
   drivers/gpu/drm/amd/amdkfd/kfd_crat.c:801:9: note: Null pointer dereference
    memcpy(pcrat_image, crat_table, crat_table->length);
           ^
   drivers/gpu/drm/amd/amdkfd/kfd_crat.c:405:32: warning: Shifting signed 
32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]
    if (props && (iolink->flags & CRAT_IOLINK_FLAGS_BI_DIRECTIONAL)) {
                                  ^
   drivers/gpu/drm/amd/amdkfd/kfd_crat.c:1112:26: warning: Shifting signed 
32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]
     sub_type_hdr->flags |= CRAT_IOLINK_FLAGS_BI_DIRECTIONAL;
                            ^
   drivers/gpu/drm/amd/amdkfd/kfd_crat.c:1146:11: warning: Shifting signed 
32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]
             CRAT_IOLINK_FLAGS_BI_DIRECTIONAL;
             ^
   drivers/gpu/drm/amd/amdkfd/kfd_crat.c:941:3: warning: Assignment of function 
parameter has no effect outside the function. Did you forget dereferencing it? 
[uselessAssignmentPtrArg]
     sub_type_hdr++;
     ^

vim +801 drivers/gpu/drm/amd/amdkfd/kfd_crat.c

8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  772  int 
kfd_create_crat_image_acpi(void **crat_image, size_t *size)
174de876d6d02f7 Felix Kuehling         2017-12-08  773  {
174de876d6d02f7 Felix Kuehling         2017-12-08  774          struct 
acpi_table_header *crat_table;
174de876d6d02f7 Felix Kuehling         2017-12-08  775          acpi_status 
status;
8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  776          void 
*pcrat_image;
174de876d6d02f7 Felix Kuehling         2017-12-08  777  
8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  778          if (!crat_image)
174de876d6d02f7 Felix Kuehling         2017-12-08  779                  return 
-EINVAL;
174de876d6d02f7 Felix Kuehling         2017-12-08  780  
8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  781          *crat_image = 
NULL;
8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  782  
8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  783          /* Fetch the 
CRAT table from ACPI */
174de876d6d02f7 Felix Kuehling         2017-12-08  784          status = 
acpi_get_table(CRAT_SIGNATURE, 0, &crat_table);
174de876d6d02f7 Felix Kuehling         2017-12-08  785          if (status == 
AE_NOT_FOUND) {
174de876d6d02f7 Felix Kuehling         2017-12-08  786                  
pr_warn("CRAT table not found\n");
174de876d6d02f7 Felix Kuehling         2017-12-08  787                  return 
-ENODATA;
174de876d6d02f7 Felix Kuehling         2017-12-08  788          } else if 
(ACPI_FAILURE(status)) {
174de876d6d02f7 Felix Kuehling         2017-12-08  789                  const 
char *err = acpi_format_exception(status);
174de876d6d02f7 Felix Kuehling         2017-12-08  790  
174de876d6d02f7 Felix Kuehling         2017-12-08  791                  
pr_err("CRAT table error: %s\n", err);
174de876d6d02f7 Felix Kuehling         2017-12-08  792                  return 
-EINVAL;
174de876d6d02f7 Felix Kuehling         2017-12-08  793          }
174de876d6d02f7 Felix Kuehling         2017-12-08  794  
6127896f4a27257 Huang Rui              2020-08-18  795          if 
(kfd_ignore_crat()) {
ebcfd1e276207e4 Felix Kuehling         2017-12-08  796                  
pr_info("CRAT table disabled by module option\n");
ebcfd1e276207e4 Felix Kuehling         2017-12-08  797                  return 
-ENODATA;
ebcfd1e276207e4 Felix Kuehling         2017-12-08  798          }
ebcfd1e276207e4 Felix Kuehling         2017-12-08  799  
d0e63b343e575e8 Kent Russell           2020-09-18  800          pcrat_image = 
kvmalloc(crat_table->length, GFP_KERNEL);
d0e63b343e575e8 Kent Russell           2020-09-18 @801          
memcpy(pcrat_image, crat_table, crat_table->length);
                                                                       
^^^^^^^^^^^
Dereferenced before the check for NULL

8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  802          if 
(!pcrat_image)
                                                                    ^^^^^^^^^^^^
Check.

8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  803                  return 
-ENOMEM;
174de876d6d02f7 Felix Kuehling         2017-12-08  804  
8e05247d4c23ff1 Harish Kasiviswanathan 2017-12-08  805          *crat_image = 
pcrat_image;
174de876d6d02f7 Felix Kuehling         2017-12-08  806          *size = 
crat_table->length;
174de876d6d02f7 Felix Kuehling         2017-12-08  807  
174de876d6d02f7 Felix Kuehling         2017-12-08  808          return 0;
174de876d6d02f7 Felix Kuehling         2017-12-08  809  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org 
_______________________________________________
kbuild mailing list -- kbu...@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to