[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <926f57a8-81b8-b3a9-8338-71213f1b85ac@gmx.de>
Date: Wed, 22 Dec 2021 07:56:22 +0100
From: Lino Sanfilippo <LinoSanfilippo@....de>
To: Stefan Berger <stefanb@...ux.ibm.com>, peterhuewe@....de,
jarkko@...nel.org, jgg@...pe.ca
Cc: p.rosenberger@...bus.com, linux-integrity@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v2] tpm: fix potential NULL pointer access in
tpm_del_char_device
Hi Stefan,
On 22.12.21 at 05:53, Stefan Berger wrote:
>>
>> drivers/char/tpm/tpm-chip.c | 16 +++++++++++-----
>> 1 file changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
>> index ddaeceb7e109..7960da490e72 100644
>> --- a/drivers/char/tpm/tpm-chip.c
>> +++ b/drivers/char/tpm/tpm-chip.c
>> @@ -474,13 +474,19 @@ static void tpm_del_char_device(struct tpm_chip *chip)
>> /* Make the driver uncallable. */
>> down_write(&chip->ops_sem);
>> - if (chip->flags & TPM_CHIP_FLAG_TPM2) {
>> - if (!tpm_chip_start(chip)) {
>> - tpm2_shutdown(chip, TPM2_SU_CLEAR);
>> - tpm_chip_stop(chip);
>> + /* Check if chip->ops is still valid: In case that the controller
>> + * drivers shutdown handler unregisters the controller in its
>> + * shutdown handler we are called twice and chip->ops to NULL.
>> + */
>> + if (chip->ops) {
>> + if (chip->flags & TPM_CHIP_FLAG_TPM2) {
>> + if (!tpm_chip_start(chip)) {
>> + tpm2_shutdown(chip, TPM2_SU_CLEAR);
>> + tpm_chip_stop(chip);
>> + }
>> }
>> + chip->ops = NULL;
>> }
>> - chip->ops = NULL;
>> up_write(&chip->ops_sem);
>> }
>>
>> base-commit: a7904a538933c525096ca2ccde1e60d0ee62c08e
>
>
> Fixes: 39d0099f9439 ("powerpc/pseries: Add shutdown() to vio_driver and vio_bus")
>
> Reviewed-by: Stefan Berger <stefanb@...ux.ibm.com>
>
> Tested-by: Stefan Berger <stefanb@...ux.ibm.com>
>
>
Thanks a lot for testing this.
Best regards,
Lino
Powered by blists - more mailing lists