:::::: 
:::::: Manual check reason: "low confidence static check warning: 
drivers/cxl/core/hdm.c:462:6: warning: Branch condition evaluates to a garbage 
value [clang-analyzer-core.uninitialized.Branch]"
:::::: 

CC: [email protected]
BCC: [email protected]
CC: Alison Schofield <[email protected]>
CC: Vishal Verma <[email protected]>
CC: Ira Weiny <[email protected]>
CC: Ben Widawsky <[email protected]>
CC: Dan Williams <[email protected]>
TO: Dan Williams <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git preview
head:   b282b26d11c50d48b336fedb5f74b2eca3f7b94c
commit: 89fff505a31a3c7076d4dac14a75837880b308fb [52/59] cxl/region: Enable the 
assignment of endpoint decoders to regions
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: s390-randconfig-c005-20220721 
(https://download.01.org/0day-ci/archive/20220725/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 
12fbd2d377e396ad61bce56d71c98a1eb1bebfa9)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install s390 cross compiling tool for clang build
        # apt-get install binutils-s390x-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git/commit/?id=89fff505a31a3c7076d4dac14a75837880b308fb
        git remote add cxl 
https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git
        git fetch --no-tags cxl preview
        git checkout 89fff505a31a3c7076d4dac14a75837880b308fb
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390 
clang-analyzer 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

clang-analyzer warnings: (new ones prefixed by >>)
                  ^
   include/linux/smp.h:267:42: note: expanded from macro 'get_cpu'
   #define get_cpu()               ({ preempt_disable(); __smp_processor_id(); 
})
                                                         ^~~~~~~~~~~~~~~~~~~~
   include/linux/smp.h:257:31: note: expanded from macro '__smp_processor_id'
   #define __smp_processor_id(x) raw_smp_processor_id(x)
                                 ^~~~~~~~~~~~~~~~~~~~~~~
   arch/s390/include/asm/smp.h:14:32: note: expanded from macro 
'raw_smp_processor_id'
   #define raw_smp_processor_id()  (S390_lowcore.cpu_nr)
                                   ^~~~~~~~~~~~~~~~~~~~~
   Suppressed 21 warnings (9 in non-user code, 12 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   25 warnings generated.
   drivers/gpu/drm/msm/msm_gpu_trace.h:87:1: warning: Dereference of null 
pointer [clang-analyzer-core.NullDereference]
   TRACE_EVENT(msm_gpu_freq_change,
   ^
   include/linux/tracepoint.h:553:2: note: expanded from macro 'TRACE_EVENT'
           DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
           ^
   include/linux/tracepoint.h:420:15: note: expanded from macro 'DECLARE_TRACE'
                           cpu_online(raw_smp_processor_id()),             \
                                      ^
   arch/s390/include/asm/smp.h:14:32: note: expanded from macro 
'raw_smp_processor_id'
   #define raw_smp_processor_id()  (S390_lowcore.cpu_nr)
                                   ^
   drivers/gpu/drm/msm/msm_gpu_devfreq.c:30:2: note: Taking false branch
           if (IS_ERR(opp))
           ^
   drivers/gpu/drm/msm/msm_gpu_devfreq.c:33:2: note: Calling 
'trace_msm_gpu_freq_change'
           trace_msm_gpu_freq_change(dev_pm_opp_get_freq(opp));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/msm/msm_gpu_trace.h:87:1: note: Taking true branch
   TRACE_EVENT(msm_gpu_freq_change,
   ^
   include/linux/tracepoint.h:553:2: note: expanded from macro 'TRACE_EVENT'
           DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
           ^
   include/linux/tracepoint.h:419:2: note: expanded from macro 'DECLARE_TRACE'
           __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
           ^
   include/linux/tracepoint.h:247:3: note: expanded from macro '__DECLARE_TRACE'
                   if (static_key_false(&__tracepoint_##name.key))         \
                   ^
   drivers/gpu/drm/msm/msm_gpu_trace.h:87:1: note: Dereference of null pointer
   TRACE_EVENT(msm_gpu_freq_change,
   ^
   include/linux/tracepoint.h:553:2: note: expanded from macro 'TRACE_EVENT'
           DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/tracepoint.h:420:15: note: expanded from macro 'DECLARE_TRACE'
                           cpu_online(raw_smp_processor_id()),             \
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/s390/include/asm/smp.h:14:32: note: expanded from macro 
'raw_smp_processor_id'
   #define raw_smp_processor_id()  (S390_lowcore.cpu_nr)
                                   ^
   include/linux/tracepoint.h:250:18: note: expanded from macro 
'__DECLARE_TRACE'
                                   TP_CONDITION(cond), 0);                 \
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
   include/linux/tracepoint.h:149:31: note: expanded from macro 'TP_CONDITION'
   #define TP_CONDITION(args...)   args
                                   ^
   include/linux/tracepoint.h:188:9: note: expanded from macro '__DO_TRACE'
                   if (!(cond))                                            \
                         ^~~~
   Suppressed 23 warnings (11 in non-user code, 12 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   13 warnings generated.
   drivers/w1/slaves/w1_ds2438.c:69:3: warning: Value stored to 'crc' is never 
read [clang-analyzer-deadcode.DeadStores]
                   crc = 0;
                   ^     ~
   drivers/w1/slaves/w1_ds2438.c:69:3: note: Value stored to 'crc' is never read
                   crc = 0;
                   ^     ~
   drivers/w1/slaves/w1_ds2438.c:328:9: warning: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   ret = snprintf(buf, count, "%i\n", voltage);
                         ^~~~~~~~
   drivers/w1/slaves/w1_ds2438.c:328:9: note: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11
                   ret = snprintf(buf, count, "%i\n", voltage);
                         ^~~~~~~~
   drivers/w1/slaves/w1_ds2438.c:428:9: warning: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   ret = snprintf(buf, count, "%i\n", temp);
                         ^~~~~~~~
   drivers/w1/slaves/w1_ds2438.c:428:9: note: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11
                   ret = snprintf(buf, count, "%i\n", temp);
                         ^~~~~~~~
   drivers/w1/slaves/w1_ds2438.c:449:9: warning: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   ret = snprintf(buf, count, "%u\n", voltage);
                         ^~~~~~~~
   drivers/w1/slaves/w1_ds2438.c:449:9: note: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11
                   ret = snprintf(buf, count, "%u\n", voltage);
                         ^~~~~~~~
   drivers/w1/slaves/w1_ds2438.c:470:9: warning: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   ret = snprintf(buf, count, "%u\n", voltage);
                         ^~~~~~~~
   drivers/w1/slaves/w1_ds2438.c:470:9: note: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11
                   ret = snprintf(buf, count, "%u\n", voltage);
                         ^~~~~~~~
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   22 warnings generated.
>> drivers/cxl/core/hdm.c:462:6: warning: Branch condition evaluates to a 
>> garbage value [clang-analyzer-core.uninitialized.Branch]
           if (rc)
               ^~
   drivers/cxl/core/hdm.c:403:2: note: 'rc' declared without an initial value
           int rc;
           ^~~~~~
   drivers/cxl/core/hdm.c:406:6: note: Assuming field 'region' is non-null
           if (cxled->cxld.region) {
               ^~~~~~~~~~~~~~~~~~
   drivers/cxl/core/hdm.c:406:2: note: Taking true branch
           if (cxled->cxld.region) {
           ^
   drivers/cxl/core/hdm.c:407:3: note: Taking false branch
                   dev_dbg(dev, "decoder attached to %s\n",
                   ^
   include/linux/dev_printk.h:155:2: note: expanded from macro 'dev_dbg'
           dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/dynamic_debug.h:166:2: note: expanded from macro 
'dynamic_dev_dbg'
           _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
           ^
   include/linux/dynamic_debug.h:152:2: note: expanded from macro 
'_dynamic_func_call'
           __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
           ^
   include/linux/dynamic_debug.h:133:2: note: expanded from macro 
'__dynamic_func_call'
           if (DYNAMIC_DEBUG_BRANCH(id))                   \
           ^
   drivers/cxl/core/hdm.c:407:3: note: Loop condition is false.  Exiting loop
                   dev_dbg(dev, "decoder attached to %s\n",
                   ^
   include/linux/dev_printk.h:155:2: note: expanded from macro 'dev_dbg'
           dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/dynamic_debug.h:166:2: note: expanded from macro 
'dynamic_dev_dbg'
           _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
           ^
   include/linux/dynamic_debug.h:152:2: note: expanded from macro 
'_dynamic_func_call'
           __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
           ^
   include/linux/dynamic_debug.h:131:49: note: expanded from macro 
'__dynamic_func_call'
   #define __dynamic_func_call(id, fmt, func, ...) do {    \
                                                   ^
   drivers/cxl/core/hdm.c:409:3: note: Control jumps to line 460
                   goto out;
                   ^
   drivers/cxl/core/hdm.c:462:6: note: Branch condition evaluates to a garbage 
value
           if (rc)
               ^~
   Suppressed 21 warnings (8 in non-user code, 13 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   22 warnings generated.
   drivers/cxl/core/region.c:290:16: warning: 1st function call argument is an 
uninitialized value [clang-analyzer-core.CallAndMessage]
           if (p->res && resource_size(res) == size)
                         ^
   drivers/cxl/core/region.c:361:6: note: Assuming 'rc' is 0
           if (rc)
               ^~
   drivers/cxl/core/region.c:361:2: note: Taking false branch
           if (rc)
           ^
   drivers/cxl/core/region.c:365:6: note: Assuming 'rc' is 0
           if (rc)
               ^~
   drivers/cxl/core/region.c:365:2: note: Taking false branch
           if (rc)
           ^
   drivers/cxl/core/region.c:368:6: note: Assuming 'val' is not equal to 0
           if (val)
               ^~~
   drivers/cxl/core/region.c:368:2: note: Taking true branch
           if (val)
           ^
   drivers/cxl/core/region.c:369:8: note: Calling 'alloc_hpa'
                   rc = alloc_hpa(cxlr, val);
                        ^~~~~~~~~~~~~~~~~~~~
   drivers/cxl/core/region.c:284:2: note: 'res' declared without an initial 
value
           struct resource *res;
           ^~~~~~~~~~~~~~~~~~~~
   drivers/cxl/core/region.c:287:2: note: Assuming 'debug_locks' is 0
           lockdep_assert_held_write(&cxl_region_rwsem);
           ^
   include/linux/lockdep.h:321:2: note: expanded from macro 
'lockdep_assert_held_write'
           lockdep_assert(lockdep_is_held_type(l, 0))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/lockdep.h:309:15: note: expanded from macro 'lockdep_assert'
           do { WARN_ON(debug_locks && !(cond)); } while (0)
                        ^~~~~~~~~~~
   arch/s390/include/asm/bug.h:54:25: note: expanded from macro 'WARN_ON'
           int __ret_warn_on = !!(x);                      \
                                  ^
   drivers/cxl/core/region.c:287:2: note: Left side of '&&' is false
           lockdep_assert_held_write(&cxl_region_rwsem);
           ^
   include/linux/lockdep.h:321:2: note: expanded from macro 
'lockdep_assert_held_write'
           lockdep_assert(lockdep_is_held_type(l, 0))
           ^
   include/linux/lockdep.h:309:27: note: expanded from macro 'lockdep_assert'
           do { WARN_ON(debug_locks && !(cond)); } while (0)
                                    ^
   drivers/cxl/core/region.c:287:2: note: Taking false branch
           lockdep_assert_held_write(&cxl_region_rwsem);

vim +462 drivers/cxl/core/hdm.c

cf880423b6a059 Dan Williams 2022-05-23  393  
cf880423b6a059 Dan Williams 2022-05-23  394  int cxl_dpa_alloc(struct 
cxl_endpoint_decoder *cxled, unsigned long long size)
cf880423b6a059 Dan Williams 2022-05-23  395  {
cf880423b6a059 Dan Williams 2022-05-23  396     struct cxl_memdev *cxlmd = 
cxled_to_memdev(cxled);
cf880423b6a059 Dan Williams 2022-05-23  397     resource_size_t free_ram_start, 
free_pmem_start;
cf880423b6a059 Dan Williams 2022-05-23  398     struct cxl_port *port = 
cxled_to_port(cxled);
cf880423b6a059 Dan Williams 2022-05-23  399     struct cxl_dev_state *cxlds = 
cxlmd->cxlds;
cf880423b6a059 Dan Williams 2022-05-23  400     struct device *dev = 
&cxled->cxld.dev;
cf880423b6a059 Dan Williams 2022-05-23  401     resource_size_t start, avail, 
skip;
cf880423b6a059 Dan Williams 2022-05-23  402     struct resource *p, *last;
cf880423b6a059 Dan Williams 2022-05-23  403     int rc;
cf880423b6a059 Dan Williams 2022-05-23  404  
cf880423b6a059 Dan Williams 2022-05-23  405     down_write(&cxl_dpa_rwsem);
89fff505a31a3c Dan Williams 2022-06-04  406     if (cxled->cxld.region) {
89fff505a31a3c Dan Williams 2022-06-04  407             dev_dbg(dev, "decoder 
attached to %s\n",
89fff505a31a3c Dan Williams 2022-06-04  408                     
dev_name(&cxled->cxld.region->dev));
89fff505a31a3c Dan Williams 2022-06-04  409             goto out;
89fff505a31a3c Dan Williams 2022-06-04  410     }
89fff505a31a3c Dan Williams 2022-06-04  411  
cf880423b6a059 Dan Williams 2022-05-23  412     if (cxled->cxld.flags & 
CXL_DECODER_F_ENABLE) {
cf880423b6a059 Dan Williams 2022-05-23  413             dev_dbg(dev, "decoder 
enabled\n");
cf880423b6a059 Dan Williams 2022-05-23  414             rc = -EBUSY;
cf880423b6a059 Dan Williams 2022-05-23  415             goto out;
cf880423b6a059 Dan Williams 2022-05-23  416     }
cf880423b6a059 Dan Williams 2022-05-23  417  
cf880423b6a059 Dan Williams 2022-05-23  418     for (p = cxlds->ram_res.child, 
last = NULL; p; p = p->sibling)
cf880423b6a059 Dan Williams 2022-05-23  419             last = p;
cf880423b6a059 Dan Williams 2022-05-23  420     if (last)
cf880423b6a059 Dan Williams 2022-05-23  421             free_ram_start = 
last->end + 1;
cf880423b6a059 Dan Williams 2022-05-23  422     else
cf880423b6a059 Dan Williams 2022-05-23  423             free_ram_start = 
cxlds->ram_res.start;
cf880423b6a059 Dan Williams 2022-05-23  424  
cf880423b6a059 Dan Williams 2022-05-23  425     for (p = cxlds->pmem_res.child, 
last = NULL; p; p = p->sibling)
cf880423b6a059 Dan Williams 2022-05-23  426             last = p;
cf880423b6a059 Dan Williams 2022-05-23  427     if (last)
cf880423b6a059 Dan Williams 2022-05-23  428             free_pmem_start = 
last->end + 1;
cf880423b6a059 Dan Williams 2022-05-23  429     else
cf880423b6a059 Dan Williams 2022-05-23  430             free_pmem_start = 
cxlds->pmem_res.start;
cf880423b6a059 Dan Williams 2022-05-23  431  
cf880423b6a059 Dan Williams 2022-05-23  432     if (cxled->mode == 
CXL_DECODER_RAM) {
cf880423b6a059 Dan Williams 2022-05-23  433             start = free_ram_start;
cf880423b6a059 Dan Williams 2022-05-23  434             avail = 
cxlds->ram_res.end - start + 1;
cf880423b6a059 Dan Williams 2022-05-23  435             skip = 0;
cf880423b6a059 Dan Williams 2022-05-23  436     } else if (cxled->mode == 
CXL_DECODER_PMEM) {
cf880423b6a059 Dan Williams 2022-05-23  437             resource_size_t 
skip_start, skip_end;
cf880423b6a059 Dan Williams 2022-05-23  438  
cf880423b6a059 Dan Williams 2022-05-23  439             start = free_pmem_start;
cf880423b6a059 Dan Williams 2022-05-23  440             avail = 
cxlds->pmem_res.end - start + 1;
cf880423b6a059 Dan Williams 2022-05-23  441             skip_start = 
free_ram_start;
cf880423b6a059 Dan Williams 2022-05-23  442             skip_end = start - 1;
cf880423b6a059 Dan Williams 2022-05-23  443             skip = skip_end - 
skip_start + 1;
cf880423b6a059 Dan Williams 2022-05-23  444     } else {
cf880423b6a059 Dan Williams 2022-05-23  445             dev_dbg(dev, "mode not 
set\n");
cf880423b6a059 Dan Williams 2022-05-23  446             rc = -EINVAL;
cf880423b6a059 Dan Williams 2022-05-23  447             goto out;
cf880423b6a059 Dan Williams 2022-05-23  448     }
cf880423b6a059 Dan Williams 2022-05-23  449  
cf880423b6a059 Dan Williams 2022-05-23  450     if (size > avail) {
cf880423b6a059 Dan Williams 2022-05-23  451             dev_dbg(dev, "%pa 
exceeds available %s capacity: %pa\n", &size,
cf880423b6a059 Dan Williams 2022-05-23  452                     cxled->mode == 
CXL_DECODER_RAM ? "ram" : "pmem",
cf880423b6a059 Dan Williams 2022-05-23  453                     &avail);
cf880423b6a059 Dan Williams 2022-05-23  454             rc = -ENOSPC;
cf880423b6a059 Dan Williams 2022-05-23  455             goto out;
cf880423b6a059 Dan Williams 2022-05-23  456     }
cf880423b6a059 Dan Williams 2022-05-23  457  
cf880423b6a059 Dan Williams 2022-05-23  458     rc = __cxl_dpa_reserve(cxled, 
start, size, skip);
cf880423b6a059 Dan Williams 2022-05-23  459  out:
cf880423b6a059 Dan Williams 2022-05-23  460     up_write(&cxl_dpa_rwsem);
cf880423b6a059 Dan Williams 2022-05-23  461  
cf880423b6a059 Dan Williams 2022-05-23 @462     if (rc)
cf880423b6a059 Dan Williams 2022-05-23  463             return rc;
cf880423b6a059 Dan Williams 2022-05-23  464  
cf880423b6a059 Dan Williams 2022-05-23  465     return 
devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled);
cf880423b6a059 Dan Williams 2022-05-23  466  }
cf880423b6a059 Dan Williams 2022-05-23  467  

:::::: The code at line 462 was first introduced by commit
:::::: cf880423b6a0599499c1f83542cab0b75daa29ba cxl/hdm: Add support for 
allocating DPA to an endpoint decoder

:::::: TO: Dan Williams <[email protected]>
:::::: CC: Dan Williams <[email protected]>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to