[PATCH] tpm: fix ordering bug in error path

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

 



The clear_bit of chip->dev_num ended up after the kfree of chip in the
error path of the tpm_register_hardware function.  This patch fixes
things to avoid a potential segmentation fault.

This bug was found by Coverity.

Signed-off-by: Kylene Hall <[email protected]>
---
 drivers/char/tpm/tpm.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.17-rc1/drivers/char/tpm/tpm.c	2006-04-18 15:14:45.630390500 -0500
+++ linux-2.6.17-rc1-tpm/drivers/char/tpm/tpm.c	2006-04-19 13:17:51.363688750 -0500
@@ -1139,8 +1139,8 @@ struct tpm_chip *tpm_register_hardware(s
 			chip->vendor.miscdev.name,
 			chip->vendor.miscdev.minor);
 		put_device(dev);
-		kfree(chip);
 		clear_bit(chip->dev_num, dev_mask);
+		kfree(chip);
 		return NULL;
 	}
 


-
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