Commit c447410b authored by Jarkko Sakkinen's avatar Jarkko Sakkinen Committed by Greg Kroah-Hartman

tpm: fix: return rc when devm_add_action() fails

[ Upstream commit 4f3b193d ]

Call put_device() and return error code if devm_add_action() fails.
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reported-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Fixes: 8e0ee3c9 ("tpm: fix the cleanup of struct tpm_chip")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c8a5f83f
......@@ -230,7 +230,11 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
chip->cdev.owner = dev->driver->owner;
chip->cdev.kobj.parent = &chip->dev.kobj;
devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev);
rc = devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev);
if (rc) {
put_device(&chip->dev);
return ERR_PTR(rc);
}
return chip;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment