diff options
author | Wanlong Gao <gaowanlong@cn.fujitsu.com> | 2012-05-16 12:24:28 +0400 |
---|---|---|
committer | Rajiv Andrade <srajiv@linux.vnet.ibm.com> | 2012-06-13 01:53:50 +0400 |
commit | dad79cb89254ce646906846b0f0cf7995d626710 (patch) | |
tree | 7be53c9e63a8adf4d4655ae655dbc6466e58d72a /drivers/char/tpm | |
parent | 24ebe6670de3d1f0dca11c9eb372134c7ab05503 (diff) | |
download | linux-dad79cb89254ce646906846b0f0cf7995d626710.tar.xz |
TPM: fix memleak when register hardware fails
Adding proper kfree() before returning.
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r-- | drivers/char/tpm/tpm.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 08427abf5fa5..dae254d53723 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c @@ -1413,15 +1413,12 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, "unable to misc_register %s, minor %d\n", chip->vendor.miscdev.name, chip->vendor.miscdev.minor); - put_device(chip->dev); - return NULL; + goto put_device; } if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) { misc_deregister(&chip->vendor.miscdev); - put_device(chip->dev); - - return NULL; + goto put_device; } chip->bios_dir = tpm_bios_log_setup(devname); @@ -1433,6 +1430,8 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, return chip; +put_device: + put_device(chip->dev); out_free: kfree(chip); kfree(devname); |