diff options
author | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-02-13 04:58:16 -0500 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-02-20 02:59:32 -0500 |
commit | 4f3b193dee4423d8c89c9a3e8e05f9197ea459a4 (patch) | |
tree | 56561ff7da6f2fb42e868270e6988f7218f361d4 /drivers/char | |
parent | c0b5eed110dcf520aadafefbcc40658cbdd18b95 (diff) |
tpm: fix: return rc when devm_add_action() fails
Call put_device() and return error code if devm_add_action() fails.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reported-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Fixes: 8e0ee3c9faed ("tpm: fix the cleanup of struct tpm_chip")
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tpm/tpm-chip.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 252142524ff2..274dd0123237 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c | |||
@@ -88,6 +88,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, | |||
88 | const struct tpm_class_ops *ops) | 88 | const struct tpm_class_ops *ops) |
89 | { | 89 | { |
90 | struct tpm_chip *chip; | 90 | struct tpm_chip *chip; |
91 | int rc; | ||
91 | 92 | ||
92 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 93 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
93 | if (chip == NULL) | 94 | if (chip == NULL) |
@@ -136,7 +137,11 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, | |||
136 | chip->cdev.owner = chip->pdev->driver->owner; | 137 | chip->cdev.owner = chip->pdev->driver->owner; |
137 | chip->cdev.kobj.parent = &chip->dev.kobj; | 138 | chip->cdev.kobj.parent = &chip->dev.kobj; |
138 | 139 | ||
139 | devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev); | 140 | rc = devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev); |
141 | if (rc) { | ||
142 | put_device(&chip->dev); | ||
143 | return ERR_PTR(rc); | ||
144 | } | ||
140 | 145 | ||
141 | return chip; | 146 | return chip; |
142 | } | 147 | } |