Skip to contentSkip to conversation

drivers/cxl/core/mbox.c:968 cxl_mbox_get_supported_features_filtered() error: uninitialized symbol 'u'.

PATCH New Dan Carpenter 1 participant 1 message Nov 16, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 24/28 drivers/cxl/core/mbox.c:968 cxl_mbox_get_supported_features_filtered() error: uninitialized symbol 'u'.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/djiang/linux.git cxl/fwctl
head:   81cb57f64be6af29f39bde3b3ca4203975a84377
commit: 6cf5361c36766f6ea8fc0ff6bc80407cd343168e [24/28] fwctl/cxl: Add support to filter exclusive features
config: x86_64-randconfig-161-20241116 (https://download.01.org/0day-ci/archive/20241117/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
drivers/cxl/core/mbox.c:968 cxl_mbox_get_supported_features_filtered() error: uninitialized symbol 'u'.

Old smatch warnings:
drivers/cxl/core/mbox.c:1129 cxl_walk_cel() error: we previously assumed 'cmd' could be null (see line 1114)

vim +/u +968 drivers/cxl/core/mbox.c

6cf5361c36766f Dave Jiang 2024-11-14  905  static void cxl_mbox_get_supported_features_filtered(struct cxl_mailbox *cxl_mbox,
6cf5361c36766f Dave Jiang 2024-11-14  906  						     struct cxl_mbox_cmd *mbox_cmd)
6cf5361c36766f Dave Jiang 2024-11-14  907  {
6cf5361c36766f Dave Jiang 2024-11-14  908  	struct cxl_mbox_get_sup_feats_in *feat_in = mbox_cmd->payload_in;
6cf5361c36766f Dave Jiang 2024-11-14  909  	struct cxl_mbox_get_sup_feats_out *feat_out = mbox_cmd->payload_out;
6cf5361c36766f Dave Jiang 2024-11-14  910  	const int feat_out_size = sizeof(*feat_out);
6cf5361c36766f Dave Jiang 2024-11-14  911  	struct cxl_feat_entry *pos;
6cf5361c36766f Dave Jiang 2024-11-14  912  	const int feat_ent_size = sizeof(*pos);
6cf5361c36766f Dave Jiang 2024-11-14  913  	int out_count, ents, u;
6cf5361c36766f Dave Jiang 2024-11-14  914  	u32 count;
6cf5361c36766f Dave Jiang 2024-11-14  915  	u16 start;
6cf5361c36766f Dave Jiang 2024-11-14  916  
6cf5361c36766f Dave Jiang 2024-11-14  917  	count = le32_to_cpu(feat_in->count);
6cf5361c36766f Dave Jiang 2024-11-14  918  	start = le16_to_cpu(feat_in->start_idx);
6cf5361c36766f Dave Jiang 2024-11-14  919  	ents = count / sizeof(struct cxl_feat_entry);
6cf5361c36766f Dave Jiang 2024-11-14  920  	ents -= start;
6cf5361c36766f Dave Jiang 2024-11-14  921  	if (ents < 0) {
6cf5361c36766f Dave Jiang 2024-11-14  922  		mbox_cmd->size_out = 0;
6cf5361c36766f Dave Jiang 2024-11-14  923  		mbox_cmd->return_code = CXL_MBOX_CMD_RC_INPUT;
6cf5361c36766f Dave Jiang 2024-11-14  924  		return;
6cf5361c36766f Dave Jiang 2024-11-14  925  	}
6cf5361c36766f Dave Jiang 2024-11-14  926  
6cf5361c36766f Dave Jiang 2024-11-14  927  	if (mbox_cmd->size_out < feat_out_size) {
6cf5361c36766f Dave Jiang 2024-11-14  928  		mbox_cmd->size_out = 0;
6cf5361c36766f Dave Jiang 2024-11-14  929  		mbox_cmd->return_code = CXL_MBOX_CMD_RC_INPUT;
6cf5361c36766f Dave Jiang 2024-11-14  930  		return;
6cf5361c36766f Dave Jiang 2024-11-14  931  	}
6cf5361c36766f Dave Jiang 2024-11-14  932  
6cf5361c36766f Dave Jiang 2024-11-14  933  	feat_out->supported_feats =
6cf5361c36766f Dave Jiang 2024-11-14  934  		cpu_to_le16(cxl_mbox->num_user_feats);
6cf5361c36766f Dave Jiang 2024-11-14  935  	if (ents == 0) {
6cf5361c36766f Dave Jiang 2024-11-14  936  		feat_out->num_entries = cpu_to_le16(0);
6cf5361c36766f Dave Jiang 2024-11-14  937  		mbox_cmd->size_out = feat_out_size;
6cf5361c36766f Dave Jiang 2024-11-14  938  		mbox_cmd->return_code = CXL_MBOX_CMD_RC_SUCCESS;
6cf5361c36766f Dave Jiang 2024-11-14  939  		return;
6cf5361c36766f Dave Jiang 2024-11-14  940  	}
6cf5361c36766f Dave Jiang 2024-11-14  941  
6cf5361c36766f Dave Jiang 2024-11-14  942  	pos = &feat_out->ents[0];
6cf5361c36766f Dave Jiang 2024-11-14  943  	out_count = feat_out_size;
6cf5361c36766f Dave Jiang 2024-11-14  944  	for (int i = 0, u = 0; i < cxl_mbox->num_features; i++) {
                                                                ^^^^^

u is accidentally re-declared here. ;)

6cf5361c36766f Dave Jiang 2024-11-14  945  		struct cxl_feature *feat = &cxl_mbox->entries[i];
6cf5361c36766f Dave Jiang 2024-11-14  946  
6cf5361c36766f Dave Jiang 2024-11-14  947  		if (feat->exclusive)
6cf5361c36766f Dave Jiang 2024-11-14  948  			continue;
6cf5361c36766f Dave Jiang 2024-11-14  949  
6cf5361c36766f Dave Jiang 2024-11-14  950  		if (u < start) {
6cf5361c36766f Dave Jiang 2024-11-14  951  			u++;
6cf5361c36766f Dave Jiang 2024-11-14  952  			continue;
6cf5361c36766f Dave Jiang 2024-11-14  953  		}
6cf5361c36766f Dave Jiang 2024-11-14  954  
6cf5361c36766f Dave Jiang 2024-11-14  955  		memcpy(pos, &feat->entry, feat_ent_size);
6cf5361c36766f Dave Jiang 2024-11-14  956  		out_count += feat_ent_size;
6cf5361c36766f Dave Jiang 2024-11-14  957  		pos++;
6cf5361c36766f Dave Jiang 2024-11-14  958  		u++;
6cf5361c36766f Dave Jiang 2024-11-14  959  
6cf5361c36766f Dave Jiang 2024-11-14  960  		if (u == count)
6cf5361c36766f Dave Jiang 2024-11-14  961  			break;
6cf5361c36766f Dave Jiang 2024-11-14  962  
6cf5361c36766f Dave Jiang 2024-11-14  963  		/* Make sure it does not go over total output buffer size */
6cf5361c36766f Dave Jiang 2024-11-14  964  		if (out_count + feat_ent_size >= mbox_cmd->size_out)
6cf5361c36766f Dave Jiang 2024-11-14  965  			break;
6cf5361c36766f Dave Jiang 2024-11-14  966  	}
6cf5361c36766f Dave Jiang 2024-11-14  967  
6cf5361c36766f Dave Jiang 2024-11-14 @968  	feat_out->num_entries = cpu_to_le16(u);
6cf5361c36766f Dave Jiang 2024-11-14  969  	mbox_cmd->size_out = out_count;
6cf5361c36766f Dave Jiang 2024-11-14  970  	mbox_cmd->return_code = CXL_MBOX_CMD_RC_SUCCESS;
6cf5361c36766f Dave Jiang 2024-11-14  971  }
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki