Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tpm: use devm_add_action_or_reset

If devm_add_action() fails we are explicitly calling put_device() to
free the resources allocated. Lets use the helper
devm_add_action_or_reset() and return directly in case of error, as we
know that the cleanup function has been already called by the helper if
there was any error.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

authored by

Sudip Mukherjee and committed by
Jarkko Sakkinen
2b88cd96 fa7539b2

+4 -4
+4 -4
drivers/char/tpm/tpm-chip.c
··· 213 213 if (IS_ERR(chip)) 214 214 return chip; 215 215 216 - rc = devm_add_action(pdev, (void (*)(void *)) put_device, &chip->dev); 217 - if (rc) { 218 - put_device(&chip->dev); 216 + rc = devm_add_action_or_reset(pdev, 217 + (void (*)(void *)) put_device, 218 + &chip->dev); 219 + if (rc) 219 220 return ERR_PTR(rc); 220 - } 221 221 222 222 dev_set_drvdata(pdev, chip); 223 223