tpm: fix up the tpm_class shutdown_pre pointer when created
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Mar 2023 18:18:41 +0000 (19:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 14:16:45 +0000 (15:16 +0100)
commita010eb8812435015118662b23be799670f641a83
tree9216cc00a6e72c45e5c153dc0760f97c05f94f83
parentd2fff09656369d5465585ad2c72d8ba8ada758b5
tpm: fix up the tpm_class shutdown_pre pointer when created

Do not wait until long after the struct class has been created to set
the shutdown_pre pointer for the tpm_class, assign it right away.

This is the only in-kernel offender that tries to modify the
device->class pointer contents after it has been assigned to a device,
so fix that up by doing the function pointer assignment before it is
matched with the device.  Because of this, the patch should go through
the driver core tree to allow later changes to struct device to be
possible.

Cc: Peter Huewe <peterhuewe@gmx.de>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-integrity@vger.kernel.org
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/r/20230313181843.1207845-10-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/tpm/tpm-chip.c
drivers/char/tpm/tpm-interface.c
drivers/char/tpm/tpm.h