Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [djiang:cxl/fwctl 24/28] drivers/cxl/features.c:162:12: warning: variable 'out_size' is uninitialized when used here
@ 2024-12-14  8:42 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-12-14  8:42 UTC (permalink / raw)
  To: Dave Jiang; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/djiang/linux.git cxl/fwctl
head:   c3c1ca00092765212f4eb49d2aaffb2003beb33b
commit: 2a47b406a8cd060676e6d34f7a21e486770a02a3 [24/28] cxl: Add support to handle user feature commands for get feature
config: i386-buildonly-randconfig-004-20241214 (https://download.01.org/0day-ci/archive/20241214/202412141609.PvUKLbQO-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241214/202412141609.PvUKLbQO-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412141609.PvUKLbQO-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/cxl/features.c:5:
   In file included from include/linux/pci.h:1650:
   In file included from include/linux/dmapool.h:14:
   In file included from include/linux/scatterlist.h:8:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   drivers/cxl/features.c:60:10: warning: expression which evaluates to zero treated as a null pointer constant of type 'struct cxl_feat_entry *' [-Wnon-literal-null-conversion]
      60 |                 return false;
         |                        ^~~~~
   drivers/cxl/features.c:64:10: warning: expression which evaluates to zero treated as a null pointer constant of type 'struct cxl_feat_entry *' [-Wnon-literal-null-conversion]
      64 |                 return false;
         |                        ^~~~~
>> drivers/cxl/features.c:162:12: warning: variable 'out_size' is uninitialized when used here [-Wuninitialized]
     162 |                 kvzalloc(out_size, GFP_KERNEL);
         |                          ^~~~~~~~
   include/linux/slab.h:1026:44: note: expanded from macro 'kvzalloc'
    1026 | #define kvzalloc(_size, _flags)                 kvmalloc(_size, (_flags)|__GFP_ZERO)
         |                                                          ^~~~~
   include/linux/slab.h:1024:49: note: expanded from macro 'kvmalloc'
    1024 | #define kvmalloc(_size, _flags)                 kvmalloc_node(_size, _flags, NUMA_NO_NODE)
         |                                                               ^~~~~
   include/linux/slab.h:1022:63: note: expanded from macro 'kvmalloc_node'
    1022 | #define kvmalloc_node(...)                      alloc_hooks(kvmalloc_node_noprof(__VA_ARGS__))
         |                                                                                  ^~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/slab.h:785:40: note: expanded from macro 'PASS_BUCKET_PARAMS'
     785 | #define PASS_BUCKET_PARAMS(_size, _b)   (_size)
         |                                          ^~~~~
   include/linux/alloc_tag.h:214:31: note: expanded from macro 'alloc_hooks'
     214 |         alloc_hooks_tag(&_alloc_tag, _do_alloc);                        \
         |                                      ^~~~~~~~~
   include/linux/alloc_tag.h:206:27: note: expanded from macro 'alloc_hooks_tag'
     206 |         typeof(_do_alloc) _res = _do_alloc;                             \
         |                                  ^~~~~~~~~
   drivers/cxl/features.c:145:17: note: initialize the variable 'out_size' to silence this warning
     145 |         size_t out_size;
         |                        ^
         |                         = 0
   4 warnings generated.


vim +/out_size +162 drivers/cxl/features.c

   138	
   139	static void *cxlctl_get_feature(struct cxl_features_state *cfs,
   140					const struct fwctl_rpc_cxl *rpc_in,
   141					size_t *out_len)
   142	{
   143		struct cxl_mbox_get_feat_in feat_in;
   144		u16 offset, count, return_code;
   145		size_t out_size;
   146		void *feat_out;
   147	
   148		if (rpc_in->op_size != sizeof(feat_in))
   149			return ERR_PTR(-EINVAL);
   150	
   151		if (copy_from_user(&feat_in, u64_to_user_ptr(rpc_in->in_payload),
   152				   rpc_in->op_size))
   153			return ERR_PTR(-EFAULT);
   154	
   155		offset = le16_to_cpu(feat_in.offset);
   156		count = le16_to_cpu(feat_in.count);
   157	
   158		if (!count)
   159			return ERR_PTR(-EINVAL);
   160	
   161		struct fwctl_rpc_cxl_out *rpc_out __free(kvfree) =
 > 162			kvzalloc(out_size, GFP_KERNEL);
   163		if (!rpc_out)
   164			return ERR_PTR(-ENOMEM);
   165	
   166		feat_out = (void *)rpc_out->payload;
   167		out_size = cxl_get_feature(cfs->features, feat_in.uuid,
   168					   feat_in.selection, feat_out,
   169					   count, offset, &return_code);
   170		*out_len = sizeof(struct fwctl_rpc_cxl_out);
   171		if (!out_size) {
   172			rpc_out->size = 0;
   173			rpc_out->retval = return_code;
   174			return no_free_ptr(rpc_out);
   175		}
   176	
   177		rpc_out->size = out_size;
   178		rpc_out->retval = CXL_MBOX_CMD_RC_SUCCESS;
   179		*out_len += out_size;
   180	
   181		return no_free_ptr(rpc_out);
   182	}
   183	

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-14  8:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-14  8:42 [djiang:cxl/fwctl 24/28] drivers/cxl/features.c:162:12: warning: variable 'out_size' is uninitialized when used here kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox