lkml.org 
[lkml]   [2019]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4.19 001/106] tpm: use tpm_try_get_ops() in tpm-sysfs.c.
On Sun 2019-10-06 19:20:07, Greg Kroah-Hartman wrote:
> From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
>
> commit 2677ca98ae377517930c183248221f69f771c921 upstream
>
> Use tpm_try_get_ops() in tpm-sysfs.c so that we can consider moving
> other decorations (locking, localities, power management for example)
> inside it. This direction can be of course taken only after other call
> sites for tpm_transmit() have been treated in the same way.

This changes locking completely:

> @@ -244,10 +274,12 @@ static ssize_t cancel_store(struct device *dev, struct device_attribute *attr,
> const char *buf, size_t count)
> {
> struct tpm_chip *chip = to_tpm_chip(dev);
> - if (chip == NULL)
> +
> + if (tpm_try_get_ops(chip))
> return 0;
>
> chip->ops->cancel(chip);
> + tpm_put_ops(chip);
> return count;
> }
> static DEVICE_ATTR_WO(cancel);

For example this did not have any locking, and is now protected by

get_device(&chip->dev);

down_read(&chip->ops_sem);

. Is that intended? Is this known to fix any bugs?

Best regards,
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2019-10-08 14:51    [W:0.347 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site