Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

char: tpm: cr50_i2c: Suppress duplicated error message in .remove()

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>

authored by

Uwe Kleine-König and committed by
Jarkko Sakkinen
e0687fe9 9c438fde

+2 -2
+2 -2
drivers/char/tpm/tpm_tis_i2c_cr50.c
··· 769 769 struct device *dev = &client->dev; 770 770 771 771 if (!chip) { 772 - dev_err(dev, "Could not get client data at remove\n"); 773 - return -ENODEV; 772 + dev_crit(dev, "Could not get client data at remove, memory corruption ahead\n"); 773 + return 0; 774 774 } 775 775 776 776 tpm_chip_unregister(chip);