[PATCH v7 14/14] nvme-auth: allow to update pre-provisioned keys

kernel test robot lkp at intel.com
Thu Nov 26 13:15:40 PST 2026


Hi Hannes,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 68099cf27253a8c89d703a282d3d811446d9453b]

url:    https://github.com/intel-lab-lkp/linux/commits/Hannes-Reinecke/nvme-auth-modify-nvme_auth_transform_key-to-return-status/20261126-151219
base:   68099cf27253a8c89d703a282d3d811446d9453b
patch link:    https://lore.kernel.org/r/20261126-dhchap-keyring-v4-v7-14-ee438ffea527%40kernel.org
patch subject: [PATCH v7 14/14] nvme-auth: allow to update pre-provisioned keys
config: hexagon-randconfig-1001-20261127 (https://download.01.org/0day-ci/archive/20261127/20261127044024.YlqHcQQx-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project fb29ca8163c3309160711e5a14eb46bc6d4fdad2)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261127/20261127044024.YlqHcQQx-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 at intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261127044024.YlqHcQQx-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/nvme/host/sysfs.c:891:17: warning: variable 'old_key' is uninitialized when used here [-Wuninitialized]
     891 |             key_serial(old_key) != key_serial(key)) {
         |                        ^~~~~~~
   drivers/nvme/host/sysfs.c:853:27: note: initialize the variable 'old_key' to silence this warning
     853 |         struct key *key, *old_key;
         |                                  ^
         |                                   = NULL
   drivers/nvme/host/sysfs.c:996:17: warning: variable 'old_key' is uninitialized when used here [-Wuninitialized]
     996 |             key_serial(old_key) != key_serial(key)) {
         |                        ^~~~~~~
   drivers/nvme/host/sysfs.c:959:27: note: initialize the variable 'old_key' to silence this warning
     959 |         struct key *key, *old_key;
         |                                  ^
         |                                   = NULL
   2 warnings generated.


vim +/old_key +891 drivers/nvme/host/sysfs.c

   848	
   849	static ssize_t dhchap_secret_store(struct device *dev,
   850			struct device_attribute *attr, const char *buf, size_t count)
   851	{
   852		struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
   853		struct key *key, *old_key;
   854		char *dhchap_secret;
   855		bool generated = false;
   856		size_t len;
   857		int ret;
   858	
   859		if (!ctrl->host_key || !count)
   860			return -EINVAL;
   861	
   862		len = strcspn(buf, "\n");
   863		dhchap_secret = kzalloc(len + 1, GFP_KERNEL);
   864		if (!dhchap_secret)
   865			return -ENOMEM;
   866		memcpy(dhchap_secret, buf, len);
   867		nvme_auth_stop(ctrl);
   868	
   869		key = nvme_auth_extract_key(dhchap_secret, len,
   870					    &generated);
   871		if (IS_ERR(key)) {
   872			kfree_sensitive(dhchap_secret);
   873			return PTR_ERR(key);
   874		}
   875		down_read(&key->sem);
   876		ret = key_validate(key);
   877		up_read(&key->sem);
   878		if (ret) {
   879			dev_warn(ctrl->device, "key %08x invalidated\n",
   880				 key_serial(key));
   881			if (generated) {
   882				dev_dbg(ctrl->device, "revoke host key %08x\n",
   883					key_serial(key));
   884				key_revoke(key);
   885			}
   886			key_put(key);
   887			kfree_sensitive(dhchap_secret);
   888			return ret;
   889		}
   890		if (!generated &&
 > 891		    key_serial(old_key) != key_serial(key)) {
   892			dev_warn(ctrl->device, "cannot change pre-populated key %08x\n",
   893				 key_serial(old_key));
   894			key_put(key);
   895			kfree_sensitive(dhchap_secret);
   896			return -EPERM;
   897		}
   898		mutex_lock(&ctrl->dhchap_auth_mutex);
   899		old_key = ctrl->host_key;
   900		if (old_key && old_key == key) {
   901			dev_warn(ctrl->device, "using existing key %08x\n",
   902				 key_serial(old_key));
   903			old_key = key;
   904		} else {
   905			if (ctrl->host_key_generated) {
   906				dev_dbg(ctrl->device, "revoke host key %08x\n",
   907					key_serial(old_key));
   908				key_revoke(old_key);
   909			}
   910			ctrl->host_key = key;
   911			ctrl->host_key_generated = generated;
   912		}
   913		mutex_unlock(&ctrl->dhchap_auth_mutex);
   914		key_put(old_key);
   915		kfree_sensitive(dhchap_secret);
   916		/* Start re-authentication */
   917		dev_info(ctrl->device, "re-authenticating controller\n");
   918		queue_work(nvme_wq, &ctrl->dhchap_auth_work);
   919		flush_work(&ctrl->dhchap_auth_work);
   920		return count;
   921	}
   922	

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



More information about the Linux-nvme mailing list