Re: [PATCH] TPM: cleanups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patch to add the necessary flush_schedule_work calls when canceling the
timer.

Signed-off-by: Kylene Hall <[email protected]>

On Sat, 2005-11-12 at 13:48 -0800, Andrew Morton wrote:
> Kylene Jo Hall <[email protected]> wrote:
> >
> >  +	schedule_work(&chip->work);
> >  +}
> >  +
> >  +static void timeout_work(void * ptr)
> >  +{
> >  +	struct tpm_chip *chip = (struct tpm_chip*) ptr;
> >  +
> 
> I cannot see where the tpm driver stops that timer which it has running on
> device close or on module unload.
> 
> Wherever it is, we'll now also need a flush_scheduled_work() to avoid a race
> wherein the work handler is still executing while the module gets
> unloaded.
> 

---
diff -uprN --exclude='.*' --exclude='*~' --exclude='*.o' --exclude='*.ko' --exclude='*.rej' --exclude='*.orig' --exclude='*infineon*' --exclude='*nsc*' --exclude='*mod*' linux-2.6.14/drivers/char/tpm/tpm.c linux-2.6.14-rc4-tpm/drivers/char/tpm/tpm.c
--- linux-2.6.14/drivers/char/tpm/tpm.c	2005-11-15 15:42:10.000000000 -0600
+++ linux-2.6.14-rc4-tpm/drivers/char/tpm/tpm.c	2005-11-15 14:11:20.000000000 -0600
@@ -377,6 +377,7 @@ int tpm_release(struct inode *inode, str
 	file->private_data = NULL;
 	chip->num_opens--;
 	del_singleshot_timer_sync(&chip->user_read_timer);
+	flush_scheduled_work();
 	atomic_set(&chip->data_pending, 0);
 	put_device(chip->dev);
 	kfree(chip->data_buffer);
@@ -428,6 +429,7 @@ ssize_t tpm_read(struct file * file, cha
 	int ret_size;
 
 	del_singleshot_timer_sync(&chip->user_read_timer);
+	flush_scheduled_work();
 	ret_size = atomic_read(&chip->data_pending);
 	atomic_set(&chip->data_pending, 0);
 	if (ret_size > 0) {	/* relay data */


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux