[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1337156668-19462-1-git-send-email-gaowanlong@cn.fujitsu.com>
Date: Wed, 16 May 2012 16:24:28 +0800
From: Wanlong Gao <gaowanlong@...fujitsu.com>
To: debora@...ux.vnet.ibm.com, srajiv@...ux.vnet.ibm.com
Cc: tpmdd-devel@...ts.sourceforge.net, linux-kernel@...r.kernel.org,
Wanlong Gao <gaowanlong@...fujitsu.com>
Subject: [PATCH] tpm: fix memleak when register hardware fails
Signed-off-by: Wanlong Gao <gaowanlong@...fujitsu.com>
---
drivers/char/tpm/tpm.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index ad7c732..c967919 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1405,15 +1405,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);
@@ -1425,6 +1422,8 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
return chip;
+put_device:
+ put_device(chip->dev);
out_free:
kfree(chip);
kfree(devname);
--
1.7.10
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists