* [PATCH] tpm: fix memleak when register hardware fails
@ 2012-05-16 8:24 Wanlong Gao
2012-05-23 15:31 ` Rajiv Andrade
0 siblings, 1 reply; 2+ messages in thread
From: Wanlong Gao @ 2012-05-16 8:24 UTC (permalink / raw)
To: debora, srajiv; +Cc: tpmdd-devel, linux-kernel, Wanlong Gao
Signed-off-by: Wanlong Gao <gaowanlong@cn.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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] tpm: fix memleak when register hardware fails
2012-05-16 8:24 [PATCH] tpm: fix memleak when register hardware fails Wanlong Gao
@ 2012-05-23 15:31 ` Rajiv Andrade
0 siblings, 0 replies; 2+ messages in thread
From: Rajiv Andrade @ 2012-05-23 15:31 UTC (permalink / raw)
To: Wanlong Gao; +Cc: debora, tpmdd-devel, linux-kernel
On 16/05/12 05:24, Wanlong Gao wrote:
> Signed-off-by: Wanlong Gao<gaowanlong@cn.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);
Thanks Wanlong, will merge and send James through a git-pull today.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-23 15:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-16 8:24 [PATCH] tpm: fix memleak when register hardware fails Wanlong Gao
2012-05-23 15:31 ` Rajiv Andrade
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox