Commit 6f9beccb authored by Kylene Jo Hall's avatar Kylene Jo Hall Committed by Linus Torvalds

[PATCH] tpm: fix misc name memory problem

I was using invalid memory for the miscdevice.name.  This patch fixes the
problem which was manifested by an ugly entry in /proc/misc.
Signed-off-by: default avatarKylene Hall <kjhall@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1dda8abe
...@@ -464,6 +464,7 @@ void __devexit tpm_remove(struct pci_dev *pci_dev) ...@@ -464,6 +464,7 @@ void __devexit tpm_remove(struct pci_dev *pci_dev)
pci_set_drvdata(pci_dev, NULL); pci_set_drvdata(pci_dev, NULL);
misc_deregister(&chip->vendor->miscdev); misc_deregister(&chip->vendor->miscdev);
kfree(&chip->vendor->miscdev.name);
sysfs_remove_group(&pci_dev->dev.kobj, chip->vendor->attr_group); sysfs_remove_group(&pci_dev->dev.kobj, chip->vendor->attr_group);
...@@ -526,7 +527,9 @@ EXPORT_SYMBOL_GPL(tpm_pm_resume); ...@@ -526,7 +527,9 @@ EXPORT_SYMBOL_GPL(tpm_pm_resume);
int tpm_register_hardware(struct pci_dev *pci_dev, int tpm_register_hardware(struct pci_dev *pci_dev,
struct tpm_vendor_specific *entry) struct tpm_vendor_specific *entry)
{ {
char devname[7]; #define DEVNAME_SIZE 7
char *devname;
struct tpm_chip *chip; struct tpm_chip *chip;
int i, j; int i, j;
...@@ -569,7 +572,8 @@ int tpm_register_hardware(struct pci_dev *pci_dev, ...@@ -569,7 +572,8 @@ int tpm_register_hardware(struct pci_dev *pci_dev,
else else
chip->vendor->miscdev.minor = MISC_DYNAMIC_MINOR; chip->vendor->miscdev.minor = MISC_DYNAMIC_MINOR;
snprintf(devname, sizeof(devname), "%s%d", "tpm", chip->dev_num); devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL);
scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num);
chip->vendor->miscdev.name = devname; chip->vendor->miscdev.name = devname;
chip->vendor->miscdev.dev = &(pci_dev->dev); chip->vendor->miscdev.dev = &(pci_dev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment