Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 113643
b: refs/heads/master
c: dc36d32
h: refs/heads/master
i:
  113641: cdd37b5
  113639: f01db82
v: v3
  • Loading branch information
Rajiv Andrade authored and James Morris committed Oct 10, 2008
1 parent f9cce86 commit 1cb2a0a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f89c5edb86abfac4c914f4eb808b07684164eca0
refs/heads/master: dc36d32cc5bea5e985294c79995e10a159c3019a
7 changes: 3 additions & 4 deletions trunk/drivers/char/tpm/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,20 +978,19 @@ int tpm_open(struct inode *inode, struct file *file)
goto err_out;
}

if (chip->num_opens) {
if (test_and_set_bit(0, &chip->is_open)) {
dev_dbg(chip->dev, "Another process owns this TPM\n");
rc = -EBUSY;
goto err_out;
}

chip->num_opens++;
get_device(chip->dev);

spin_unlock(&driver_lock);

chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8), GFP_KERNEL);
if (chip->data_buffer == NULL) {
chip->num_opens--;
clear_bit(0, &chip->is_open);
put_device(chip->dev);
return -ENOMEM;
}
Expand All @@ -1016,7 +1015,7 @@ int tpm_release(struct inode *inode, struct file *file)
file->private_data = NULL;
del_singleshot_timer_sync(&chip->user_read_timer);
atomic_set(&chip->data_pending, 0);
chip->num_opens--;
clear_bit(0, &chip->is_open);
put_device(chip->dev);
kfree(chip->data_buffer);
spin_unlock(&driver_lock);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/char/tpm/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct tpm_chip {
struct device *dev; /* Device stuff */

int dev_num; /* /dev/tpm# */
int num_opens; /* only one allowed */
unsigned long is_open; /* only one allowed */
int time_expired;

/* Data passed to and from the tpm via the read/write calls */
Expand Down

0 comments on commit 1cb2a0a

Please sign in to comment.