tpm_tis: extra chip->ops check on error path in tpm_tis_core_init
authorVasily Averin <vvs@virtuozzo.com>
Sat, 13 Jun 2020 14:18:33 +0000 (17:18 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Jul 2020 07:34:00 +0000 (09:34 +0200)
commit15cc8626e3284547ee0acfd853dd4b5b089ce5ea
treec62acd3f9aa8a653f52c5437018c4411602d01d9
parent5f14dab1a3a956b25cc9afe31e31a90fdcae5a17
tpm_tis: extra chip->ops check on error path in tpm_tis_core_init

[ Upstream commit ccf6fb858e17a8f8a914a1c6444d277cfedfeae6 ]

Found by smatch:
drivers/char/tpm/tpm_tis_core.c:1088 tpm_tis_core_init() warn:
 variable dereferenced before check 'chip->ops' (see line 979)

'chip->ops' is assigned in the beginning of function
in tpmm_chip_alloc->tpm_chip_alloc
and is used before first possible goto to error path.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/tpm/tpm_tis_core.c