Skip to content

Commit

Permalink
[PATCH] tpm: locking fix
Browse files Browse the repository at this point in the history
Use schedule_work() to avoid down()-in-timer-handler problem.

Signed-off-by: Kylene Hall <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Kylene Jo Hall authored and Linus Torvalds committed Nov 14, 2005
1 parent f6a2382 commit 09e12f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/char/tpm/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ static void user_reader_timeout(unsigned long ptr)
{
struct tpm_chip *chip = (struct tpm_chip *) ptr;

schedule_work(&chip->work);
}

static void timeout_work(void * ptr)
{
struct tpm_chip *chip = ptr;

down(&chip->buffer_mutex);
atomic_set(&chip->data_pending, 0);
memset(chip->data_buffer, 0, TPM_BUFSIZE);
Expand Down Expand Up @@ -527,6 +534,8 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry)
init_MUTEX(&chip->tpm_mutex);
INIT_LIST_HEAD(&chip->list);

INIT_WORK(&chip->work, timeout_work, chip);

init_timer(&chip->user_read_timer);
chip->user_read_timer.function = user_reader_timeout;
chip->user_read_timer.data = (unsigned long) chip;
Expand Down
1 change: 1 addition & 0 deletions drivers/char/tpm/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct tpm_chip {
struct semaphore buffer_mutex;

struct timer_list user_read_timer; /* user needs to claim result */
struct work_struct work;
struct semaphore tpm_mutex; /* tpm is processing */

struct tpm_vendor_specific *vendor;
Expand Down

0 comments on commit 09e12f9

Please sign in to comment.