aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/tpm/tpm.c17
-rw-r--r--drivers/char/tpm/tpm.h1
2 files changed, 7 insertions, 11 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index e3c974a6c522..71eb8c762880 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1463,7 +1463,6 @@ void tpm_dev_vendor_release(struct tpm_chip *chip)
1463 chip->vendor.release(chip->dev); 1463 chip->vendor.release(chip->dev);
1464 1464
1465 clear_bit(chip->dev_num, dev_mask); 1465 clear_bit(chip->dev_num, dev_mask);
1466 kfree(chip->vendor.miscdev.name);
1467} 1466}
1468EXPORT_SYMBOL_GPL(tpm_dev_vendor_release); 1467EXPORT_SYMBOL_GPL(tpm_dev_vendor_release);
1469 1468
@@ -1496,17 +1495,13 @@ EXPORT_SYMBOL_GPL(tpm_dev_release);
1496struct tpm_chip *tpm_register_hardware(struct device *dev, 1495struct tpm_chip *tpm_register_hardware(struct device *dev,
1497 const struct tpm_vendor_specific *entry) 1496 const struct tpm_vendor_specific *entry)
1498{ 1497{
1499#define DEVNAME_SIZE 7
1500
1501 char *devname;
1502 struct tpm_chip *chip; 1498 struct tpm_chip *chip;
1503 1499
1504 /* Driver specific per-device data */ 1500 /* Driver specific per-device data */
1505 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1501 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1506 devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL);
1507 1502
1508 if (chip == NULL || devname == NULL) 1503 if (chip == NULL)
1509 goto out_free; 1504 return NULL;
1510 1505
1511 mutex_init(&chip->buffer_mutex); 1506 mutex_init(&chip->buffer_mutex);
1512 mutex_init(&chip->tpm_mutex); 1507 mutex_init(&chip->tpm_mutex);
@@ -1531,8 +1526,9 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
1531 1526
1532 set_bit(chip->dev_num, dev_mask); 1527 set_bit(chip->dev_num, dev_mask);
1533 1528
1534 scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); 1529 scnprintf(chip->devname, sizeof(chip->devname), "%s%d", "tpm",
1535 chip->vendor.miscdev.name = devname; 1530 chip->dev_num);
1531 chip->vendor.miscdev.name = chip->devname;
1536 1532
1537 chip->vendor.miscdev.parent = dev; 1533 chip->vendor.miscdev.parent = dev;
1538 chip->dev = get_device(dev); 1534 chip->dev = get_device(dev);
@@ -1558,7 +1554,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
1558 goto put_device; 1554 goto put_device;
1559 } 1555 }
1560 1556
1561 chip->bios_dir = tpm_bios_log_setup(devname); 1557 chip->bios_dir = tpm_bios_log_setup(chip->devname);
1562 1558
1563 /* Make chip available */ 1559 /* Make chip available */
1564 spin_lock(&driver_lock); 1560 spin_lock(&driver_lock);
@@ -1571,7 +1567,6 @@ put_device:
1571 put_device(chip->dev); 1567 put_device(chip->dev);
1572out_free: 1568out_free:
1573 kfree(chip); 1569 kfree(chip);
1574 kfree(devname);
1575 return NULL; 1570 return NULL;
1576} 1571}
1577EXPORT_SYMBOL_GPL(tpm_register_hardware); 1572EXPORT_SYMBOL_GPL(tpm_register_hardware);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index a7bfc176ed43..0df18b56b2c5 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -122,6 +122,7 @@ struct tpm_chip {
122 struct device *dev; /* Device stuff */ 122 struct device *dev; /* Device stuff */
123 123
124 int dev_num; /* /dev/tpm# */ 124 int dev_num; /* /dev/tpm# */
125 char devname[7];
125 unsigned long is_open; /* only one allowed */ 126 unsigned long is_open; /* only one allowed */
126 int time_expired; 127 int time_expired;
127 128