Skip to contentSkip to conversation

crypto/asymmetric_keys/tpm2_key_rsa.c:636 tpm2_key_rsa_preparse() error: uninitialized symbol 'ret'.

PATCH In review Dan Carpenter 2 participants 2 messages May 29, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 8/9 crypto/asymmetric_keys/tpm2_key_rsa.c:636 tpm2_key_rsa_preparse() error: uninitialized symbol 'ret'.

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git tpm2key-v7
head:   892305fec7841bf841a9c19e01c999c5f4b4e831
commit: 4970b8d723c3af732b21a8bf7c1eebfb03792457 [8/9] keys: asymmetric: Add tpm2_key_rsa
config: alpha-randconfig-r081-20240529 (https://download.01.org/0day-ci/archive/20240529/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.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]/

smatch warnings:
crypto/asymmetric_keys/tpm2_key_rsa.c:636 tpm2_key_rsa_preparse() error: uninitialized symbol 'ret'.

vim +/ret +636 crypto/asymmetric_keys/tpm2_key_rsa.c

4970b8d723c3af Jarkko Sakkinen 2024-05-26  629  static int tpm2_key_rsa_preparse(struct key_preparsed_payload *prep)
4970b8d723c3af Jarkko Sakkinen 2024-05-26  630  {
4970b8d723c3af Jarkko Sakkinen 2024-05-26  631  	struct tpm2_key *key;
4970b8d723c3af Jarkko Sakkinen 2024-05-26  632  	int ret;
4970b8d723c3af Jarkko Sakkinen 2024-05-26  633  
4970b8d723c3af Jarkko Sakkinen 2024-05-26  634  	key = tpm2_key_decode(prep->data, prep->datalen);
4970b8d723c3af Jarkko Sakkinen 2024-05-26  635  	if (IS_ERR(key))
4970b8d723c3af Jarkko Sakkinen 2024-05-26 @636  		return ret;
                                                                ^^^^^^^^^^

Same. return PTR_ERR(key);

4970b8d723c3af Jarkko Sakkinen 2024-05-26  637  
4970b8d723c3af Jarkko Sakkinen 2024-05-26  638  	if (key->oid != OID_TPMLoadableKey) {
4970b8d723c3af Jarkko Sakkinen 2024-05-26  639  		kfree(key);
4970b8d723c3af Jarkko Sakkinen 2024-05-26  640  		return -EBADMSG;
4970b8d723c3af Jarkko Sakkinen 2024-05-26  641  	}
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 26 lines · Dan Carpenter
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git tpm2key-v7
head:   892305fec7841bf841a9c19e01c999c5f4b4e831
commit: 4970b8d723c3af732b21a8bf7c1eebfb03792457 [8/9] keys: asymmetric: Add tpm2_key_rsa
config: alpha-randconfig-r081-20240529 (https://download.01.org/0day-ci/archive/20240529/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.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]/

smatch warnings:
crypto/asymmetric_keys/tpm2_key_rsa.c:636 tpm2_key_rsa_preparse() error: uninitialized symbol 'ret'.

vim +/ret +636 crypto/asymmetric_keys/tpm2_key_rsa.c

4970b8d723c3af Jarkko Sakkinen 2024-05-26  629  static int tpm2_key_rsa_preparse(struct key_preparsed_payload *prep)
4970b8d723c3af Jarkko Sakkinen 2024-05-26  630  {
4970b8d723c3af Jarkko Sakkinen 2024-05-26  631  	struct tpm2_key *key;
4970b8d723c3af Jarkko Sakkinen 2024-05-26  632  	int ret;
4970b8d723c3af Jarkko Sakkinen 2024-05-26  633  
4970b8d723c3af Jarkko Sakkinen 2024-05-26  634  	key = tpm2_key_decode(prep->data, prep->datalen);
4970b8d723c3af Jarkko Sakkinen 2024-05-26  635  	if (IS_ERR(key))
4970b8d723c3af Jarkko Sakkinen 2024-05-26 @636  		return ret;
                                                                ^^^^^^^^^^
Quoted 7 lines

Same. return PTR_ERR(key);

4970b8d723c3af Jarkko Sakkinen 2024-05-26  637  
4970b8d723c3af Jarkko Sakkinen 2024-05-26  638  	if (key->oid != OID_TPMLoadableKey) {
4970b8d723c3af Jarkko Sakkinen 2024-05-26  639  		kfree(key);
4970b8d723c3af Jarkko Sakkinen 2024-05-26  640  		return -EBADMSG;
4970b8d723c3af Jarkko Sakkinen 2024-05-26  641  	}

Thanks for spotting this!

BR, Jarkko