Skip to contentSkip to conversation

TPM: Missing put_device()

PATCH New Rajiv Andrade 1 participant 2 messages Sep 24, 2008 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 TPM: Missing put_device()

In case one calling tpm_open() whilst other process is owning it, the refcount wouldn't get 0.

This patch depends on [PATCH 3/4][resubmit] TPM: rcu locking, sent on 23 Sep 2008.

---
 drivers/char/tpm/tpm.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/char/tpm/tpm.c +1 -0
index f6bbc1d..ab03b4d 100644
@@ -979,6 +979,7 @@ int tpm_open(struct inode *inode, struct file *file)
 
 	if (test_and_set_bit(0, &chip->is_open)) {
 		dev_dbg(chip->dev, "Another process owns this TPM\n");
+		put_device(chip->dev);
 		return -EBUSY;
 	}
 
Signature · 1 line
1.5.6.3
#1 lore raw

PATCH 2/2 TPM: Fixed tpm release timing

As pointed by Jonathan Corbet, the timer must be deleted before flushing the work queue in order to avoid a job being submitted after the chip had been released.

---
 drivers/char/tpm/tpm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/tpm/tpm.c +1 -1
index ab03b4d..8d090d3 100644
@@ -1004,9 +1004,9 @@ int tpm_release(struct inode *inode, struct file *file)
 {
 	struct tpm_chip *chip = file->private_data;
 
+	del_singleshot_timer_sync(&chip->user_read_timer);
 	flush_scheduled_work();
 	file->private_data = NULL;
-	del_singleshot_timer_sync(&chip->user_read_timer);
 	atomic_set(&chip->data_pending, 0);
 	kfree(chip->data_buffer);
 	clear_bit(0, &chip->is_open);
Signature · 1 line
1.5.6.3