mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Peter Huewe <peterhuewe@gmx.de>,
	Marcel Selhorst <tpmdd@selhorst.net>,
	David Howells <dhowells@redhat.com>
Cc: jmorris@namei.org,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	stable@vger.kernel.org,
	Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	tpmdd-devel@lists.sourceforge.net (moderated list:TPM DEVICE
	DRIVER), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v2 3/4] tpm: Hold the kref during tpm_chip_find_get
Date: Sat, 13 Feb 2016 15:47:06 +0200	[thread overview]
Message-ID: <1455371228-20431-4-git-send-email-jarkko.sakkinen@linux.intel.com> (raw)
In-Reply-To: <1455371228-20431-1-git-send-email-jarkko.sakkinen@linux.intel.com>

From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>

This was missed during the struct device conversion, we
need to hold a kref on the chip to make sure it isn't freed.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.cm>
Fixes: afb5abc262e9 ("tpm: two-phase chip management functions")
cc: stable@vger.kernel.org
---
 drivers/char/tpm/tpm-chip.c | 2 ++
 drivers/char/tpm/tpm.h      | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 274dd01..84a54a2 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -53,6 +53,8 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
 			chip = pos;
 			break;
 		}
+
+		get_device(&chip->dev);
 	}
 	rcu_read_unlock();
 	return chip;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 28b477e..f6bc0b3 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -200,6 +200,7 @@ struct tpm_chip {
 static inline void tpm_chip_put(struct tpm_chip *chip)
 {
 	module_put(chip->pdev->driver->owner);
+	put_device(&chip->dev);
 }
 
 static inline int tpm_read_index(int base, int index)
-- 
2.7.0

  parent reply	other threads:[~2016-02-13 13:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-13 13:47 [PATCH v2 0/4] tpm: last minute critical fixes for Linux 4.5 Jarkko Sakkinen
2016-02-13 13:47 ` [PATCH v2 1/4] tpm: fix: keep auth session intact after unseal operation Jarkko Sakkinen
2016-02-13 13:47 ` [PATCH v2 2/4] tpm: fix: rollback when devm_add_action() fails Jarkko Sakkinen
2016-02-13 13:47 ` Jarkko Sakkinen [this message]
2016-02-13 13:47 ` [PATCH v2 4/4] tpm_eventlog.c: fix binary_bios_measurements Jarkko Sakkinen
2016-02-13 21:55 ` [PATCH v2 0/4] tpm: last minute critical fixes for Linux 4.5 Jason Gunthorpe
2016-02-14  3:27   ` Jarkko Sakkinen
2016-02-14  3:30     ` 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=1455371228-20431-4-git-send-email-jarkko.sakkinen@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=dhowells@redhat.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=stable@vger.kernel.org \
    --cc=tpmdd-devel@lists.sourceforge.net \
    --cc=tpmdd@selhorst.net \
    /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

all inboxes | Powered by JetHome®