[hare-scsi-devel:auth.v5 11/12] drivers/nvme/target/fabrics-cmd-auth.c:346:30: sparse: sparse: incorrect type in assignment (different base types)

From: kernel test robot
Date: Fri Nov 26 2021 - 02:48:24 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/hare/scsi-devel.git auth.v5
head: 1d58df043579d325e3c2a5926a89282183393f49
commit: 6ca636fe7f5c7c1d040fb4328ef7b47a62165a7e [11/12] nvmet-auth: Diffie-Hellman key exchange support
config: nios2-randconfig-s031-20211115 (https://download.01.org/0day-ci/archive/20211126/202111261548.YAoOcBe0-lkp@xxxxxxxxx/config)
compiler: nios2-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/hare/scsi-devel.git/commit/?id=6ca636fe7f5c7c1d040fb4328ef7b47a62165a7e
git remote add hare-scsi-devel https://git.kernel.org/pub/scm/linux/kernel/git/hare/scsi-devel.git
git fetch --no-tags hare-scsi-devel auth.v5
git checkout 6ca636fe7f5c7c1d040fb4328ef7b47a62165a7e
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=nios2

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)
drivers/nvme/target/fabrics-cmd-auth.c:20:30: sparse: sparse: invalid assignment: |=
drivers/nvme/target/fabrics-cmd-auth.c:20:30: sparse: left side has type restricted __le32
drivers/nvme/target/fabrics-cmd-auth.c:20:30: sparse: right side has type int
drivers/nvme/target/fabrics-cmd-auth.c:84:22: sparse: sparse: cast to restricted __le32
drivers/nvme/target/fabrics-cmd-auth.c:84:22: sparse: sparse: cast from restricted __le16
>> drivers/nvme/target/fabrics-cmd-auth.c:346:30: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le16 [usertype] dhvlen @@ got restricted __le32 [usertype] @@
drivers/nvme/target/fabrics-cmd-auth.c:346:30: sparse: expected restricted __le16 [usertype] dhvlen
drivers/nvme/target/fabrics-cmd-auth.c:346:30: sparse: got restricted __le32 [usertype]

vim +346 drivers/nvme/target/fabrics-cmd-auth.c

315
316 static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al)
317 {
318 struct nvmf_auth_dhchap_challenge_data *data = d;
319 struct nvmet_ctrl *ctrl = req->sq->ctrl;
320 int ret = 0;
321 int hash_len = nvme_auth_hmac_hash_len(ctrl->shash_id);
322 int data_size = sizeof(*d) + hash_len;
323
324 if (ctrl->dh_tfm)
325 data_size += ctrl->dh_keysize;
326 if (al < data_size) {
327 pr_debug("%s: buffer too small (al %d need %d)\n", __func__,
328 al, data_size);
329 return -EINVAL;
330 }
331 memset(data, 0, data_size);
332 req->sq->dhchap_s1 = ctrl->dhchap_seqnum++;
333 data->auth_type = NVME_AUTH_DHCHAP_MESSAGES;
334 data->auth_id = NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE;
335 data->t_id = cpu_to_le16(req->sq->dhchap_tid);
336 data->hashid = ctrl->shash_id;
337 data->hl = hash_len;
338 data->seqnum = cpu_to_le32(req->sq->dhchap_s1);
339 req->sq->dhchap_c1 = kmalloc(data->hl, GFP_KERNEL);
340 if (!req->sq->dhchap_c1)
341 return -ENOMEM;
342 get_random_bytes(req->sq->dhchap_c1, data->hl);
343 memcpy(data->cval, req->sq->dhchap_c1, data->hl);
344 if (ctrl->dh_tfm) {
345 data->dhgid = ctrl->dh_gid;
> 346 data->dhvlen = cpu_to_le32(ctrl->dh_keysize);
347 ret = nvmet_auth_ctrl_exponential(req, data->cval + data->hl,
348 ctrl->dh_keysize);
349 }
350 pr_debug("%s: ctrl %d qid %d seq %d transaction %d hl %d dhvlen %d\n",
351 __func__, ctrl->cntlid, req->sq->qid, req->sq->dhchap_s1,
352 req->sq->dhchap_tid, data->hl, ctrl->dh_keysize);
353 return ret;
354 }
355

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx