On Thu, May 28, 2020 at 11:10:57AM -0700, James Bottomley wrote: > It has been reported that some TIS based TPMs are giving unexpected > errors when using the O_NONBLOCK path of the TPM device. The problem > is that some TPMs don't like it when you get and then relinquish a > locality (as the tpm_try_get_ops()/tpm_put_ops() pair does) without > sending a command. This currently happens all the time in the > O_NONBLOCK write path. Fix this by moving the tpm_try_get_ops() > further down the code to after the O_NONBLOCK determination is made. > This is safe because the priv->buffer_mutex still protects the priv > state being modified. > > BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206275 > Fixes: d23d12484307 ("tpm: fix invalid locking in NONBLOCKING mode") > Reported-by: Mario Limonciello <Mario.Limonciello@xxxxxxxx> > Tested-by: Alex Guzman <alex@xxxxxxxxx> > Cc: stable@xxxxxxxxxxxxxxx > Reviewed-by: Jerry Snitselaar <jsnitsel@xxxxxxxxxx> > Signed-off-by: James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> Thanks a lot! Merging this soon. Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> /Jarko