mirror of
https://github.com/torvalds/linux.git
synced 2024-12-15 15:41:58 +00:00
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>
This commit is contained in:
parent
24ebe6670d
commit
dad79cb892
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user