]> git.baikalelectronics.ru Git - kernel.git/commit
char: tpm: cr50_i2c: Suppress duplicated error message in .remove()
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 26 Apr 2022 08:06:02 +0000 (10:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:40 +0000 (10:22 +0200)
commite6ca6b16926d735b9ee120b79decb9a7b14f9c72
tree11864bfdd9a03425013c44344fd845f32dd3aebe
parent20064171daf1ba06ad1c85d9f61a307579189db0
char: tpm: cr50_i2c: Suppress duplicated error message in .remove()

[ Upstream commit f5dcf10c5f0aaeacf5ac9eac6645c3bcc10c218f ]

Returning an error value in an i2c remove callback results in an error
message being emitted by the i2c core, but otherwise it doesn't make a
difference. The device goes away anyhow and the devm cleanups are
called.

As tpm_cr50_i2c_remove() emits an error message already and the
additional error message by the i2c core doesn't add any useful
information, change the return value to zero to suppress this error
message.

Note that if i2c_clientdata is NULL, there is something really fishy.
Assuming no memory corruption happened (then all bets are lost anyhow),
tpm_cr50_i2c_remove() is only called after tpm_cr50_i2c_probe() returned
successfully. So there was a tpm chip registered before and after
tpm_cr50_i2c_remove() its privdata is freed but the associated character
device isn't removed. If after that happened userspace accesses the
character device it's likely that the freed memory is accessed. For that
reason the warning message is made a bit more frightening.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/tpm/tpm_tis_i2c_cr50.c