All of lore.kernel.org
 help / color / mirror / Atom feed
* [jarkko-tpmdd:tpm2key-v4 5/5] crypto/asymmetric_keys/tpm2_key_rsa.c:273:22: warning: unused variable 'offset'
@ 2024-05-22 11:23 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-05-22 11:23 UTC (permalink / raw)
  To: James Prestwood; +Cc: oe-kbuild-all, Jarkko Sakkinen

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git tpm2key-v4
head:   8d6000fe712d525bf767a9fbe7028d809adaf79e
commit: 8d6000fe712d525bf767a9fbe7028d809adaf79e [5/5] keys: asymmetric: ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20240522/202405221925.Wje4IgfU-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240522/202405221925.Wje4IgfU-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/202405221925.Wje4IgfU-lkp@intel.com/

All warnings (new ones prefixed by >>):

   crypto/asymmetric_keys/tpm2_key_rsa.c: In function '__tpm2_key_rsa_decrypt':
>> crypto/asymmetric_keys/tpm2_key_rsa.c:273:22: warning: unused variable 'offset' [-Wunused-variable]
     273 |         unsigned int offset = 0;
         |                      ^~~~~~


vim +/offset +273 crypto/asymmetric_keys/tpm2_key_rsa.c

   267	
   268	static int __tpm2_key_rsa_decrypt(struct tpm_chip *chip,
   269					  struct tpm2_key_rsa *key,
   270					  struct kernel_pkey_params *params,
   271					  const void *in, int in_len, void *out)
   272	{
 > 273		unsigned int offset = 0;
   274		u32 key_handle = 0;
   275		struct tpm_buf buf;
   276		u16 decrypted_len;
   277		u32 parent;
   278		u8 *pos;
   279		int ret;
   280	
   281		ret = tpm_try_get_ops(chip);
   282		if (ret)
   283			return ret;
   284	
   285		ret = tpm2_start_auth_session(chip);
   286		if (ret)
   287			goto err_ops;
   288	
   289		parent = key->key.parent;
   290	
   291		ret = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_LOAD);
   292		if (ret < 0)
   293			goto err_auth;
   294	
   295		tpm_buf_append_name(chip, &buf, parent, NULL);
   296		tpm_buf_append_hmac_session(chip, &buf, TPM2_SA_CONTINUE_SESSION |
   297					    TPM2_SA_ENCRYPT, NULL, 0);
   298		tpm_buf_append(&buf, key->key.blob, key->key.blob_len);
   299		if (buf.flags & TPM_BUF_OVERFLOW) {
   300			ret = -E2BIG;
   301			goto err_buf;
   302		}
   303		tpm_buf_fill_hmac_session(chip, &buf);
   304		ret = tpm_transmit_cmd(chip, &buf, 4, "RSA key loading");
   305		ret = tpm_buf_check_hmac_response(chip, &buf, ret);
   306		if (ret) {
   307			ret = -EIO;
   308			goto err_buf;
   309		}
   310		key_handle = be32_to_cpup((__be32 *)&buf.data[TPM_HEADER_SIZE]);
   311	
   312		tpm_buf_reset(&buf, TPM2_ST_SESSIONS, TPM2_CC_RSA_DECRYPT);
   313		tpm_buf_append_name(chip, &buf, key_handle, NULL);
   314		tpm_buf_append_hmac_session(chip, &buf, TPM2_SA_DECRYPT, NULL, 0);
   315		tpm_buf_append_u16(&buf, in_len);
   316		tpm_buf_append(&buf, in, in_len);
   317		tpm_buf_append_u16(&buf, TPM_ALG_NULL);
   318		tpm_buf_append_u16(&buf, 0);
   319		tpm_buf_fill_hmac_session(chip, &buf);
   320		ret = tpm_transmit_cmd(chip, &buf, 4, "RSA key decrypting");
   321		ret = tpm_buf_check_hmac_response(chip, &buf, ret);
   322		if (ret) {
   323			ret = -EIO;
   324			goto err_blob;
   325		}
   326	
   327		pos = buf.data + TPM_HEADER_SIZE + 4;
   328		decrypted_len = be16_to_cpup((__be16 *)pos);
   329		pos += 2;
   330	
   331		if (params->out_len < decrypted_len) {
   332			ret = -EMSGSIZE;
   333			goto err_blob;
   334		}
   335	
   336		memcpy(out, pos, decrypted_len);
   337		ret = decrypted_len;
   338	
   339	err_blob:
   340		tpm2_flush_context(chip, key_handle);
   341	
   342	err_buf:
   343		tpm_buf_destroy(&buf);
   344	
   345	err_auth:
   346		if (ret < 0)
   347			tpm2_end_auth_session(chip);
   348	
   349	err_ops:
   350		tpm_put_ops(chip);
   351		return ret;
   352	}
   353	

-- 
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-05-22 11:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-22 11:23 [jarkko-tpmdd:tpm2key-v4 5/5] crypto/asymmetric_keys/tpm2_key_rsa.c:273:22: warning: unused variable 'offset' kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.