From: stefanb@linux.vnet.ibm.com (Stefan Berger)
To: linux-security-module@vger.kernel.org
Subject: [PATCH 1/2] tpm: Implement public tpm_put_chip() to release reference to chip
Date: Tue, 26 Jun 2018 15:30:39 -0400 [thread overview]
Message-ID: <20180626193040.2509798-2-stefanb@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180626193040.2509798-1-stefanb@linux.vnet.ibm.com>
Some subsystems that got a hold of a TPM chip through tpm_default_chip()
need a way to release the reference to the TPM chip when they shut down.
The tpm_put_chip() function enables this.
Signed-off-by: Stefan Berger <stefanb@liux.vnet.ibm.com>
---
drivers/char/tpm/tpm-chip.c | 10 ++++++++++
include/linux/tpm.h | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 46caadca916a..c744289d82e0 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -80,6 +80,16 @@ void tpm_put_ops(struct tpm_chip *chip)
}
EXPORT_SYMBOL_GPL(tpm_put_ops);
+/**
+ * tpm_put_chip() - Releae a ref to the tpm_chip
+ * @chip: Chip to put
+ */
+void tpm_put_chip(struct tpm_chip *chip)
+{
+ put_device(&chip->dev);
+}
+EXPORT_SYMBOL_GPL(tpm_put_chip);
+
/**
* tpm_default_chip() - find a TPM chip and get a reference to it
*/
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index e0e51c49a0e6..889dafe739e1 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -62,6 +62,7 @@ extern int tpm_unseal_trusted(struct tpm_chip *chip,
struct trusted_key_payload *payload,
struct trusted_key_options *options);
extern struct tpm_chip *tpm_default_chip(void);
+extern void tpm_put_chip(struct tpm_chip *chip);
#else
static inline int tpm_is_tpm2(struct tpm_chip *chip)
{
@@ -101,5 +102,8 @@ static inline struct tpm_chip *tpm_default_chip(void)
{
return NULL;
}
+static inline void tpm_put_chip(struct tpm_chip *chip)
+{
+}
#endif
#endif
--
2.17.1
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-06-26 19:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 19:30 [PATCH 0/2] Convert trusted keys to find and use the default TPM chip Stefan Berger
2018-06-26 19:30 ` Stefan Berger [this message]
2018-07-03 15:21 ` [PATCH 1/2] tpm: Implement public tpm_put_chip() to release reference to chip Jarkko Sakkinen
2018-06-26 19:30 ` [PATCH 2/2] KEYS: trusted: Find tpm_chip and use it until module shutdown Stefan Berger
2018-07-03 15:24 ` Jarkko Sakkinen
2018-07-03 15:26 ` James Bottomley
2018-07-03 16:51 ` Jarkko Sakkinen
2018-07-03 18:51 ` James Morris
2018-07-03 19:06 ` James Bottomley
2018-07-04 13:52 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180626193040.2509798-2-stefanb@linux.vnet.ibm.com \
--to=stefanb@linux.vnet.ibm.com \
--cc=linux-security-module@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).