public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tpm_tis: missing platform_driver_unregister() on error in init_tis()
@ 2013-04-25  7:07 Wei Yongjun
  2013-04-26 14:28 ` [tpmdd-devel] " Kent Yoder
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2013-04-25  7:07 UTC (permalink / raw)
  To: key, mail, tpmdd, tpmdd; +Cc: yongjun_wei, tpmdd-devel, linux-kernel

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Add the missing platform_driver_unregister() before return
from init_tis() in the device register error handling case.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/char/tpm/tpm_tis.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 8a41b6b..2f777a4 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -884,13 +884,20 @@ static int __init init_tis(void)
 	rc = platform_driver_register(&tis_drv);
 	if (rc < 0)
 		return rc;
-	if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0)))
-		return PTR_ERR(pdev);
-	if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) {
-		platform_device_unregister(pdev);
-		platform_driver_unregister(&tis_drv);
+	pdev = platform_device_register_simple("tpm_tis", -1, NULL, 0);
+	if (IS_ERR(pdev)) {
+		rc = PTR_ERR(pdev);
+		goto err_dev;
 	}
-	return rc;
+	rc = tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0);
+	if (rc)
+		goto err_init;
+	return 0;
+err_init:
+	platform_device_unregister(pdev);
+err_dev:
+	platform_driver_unregister(&tis_drv);
+	return rc;
 }
 
 static void __exit cleanup_tis(void)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-26 14:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25  7:07 [PATCH] tpm_tis: missing platform_driver_unregister() on error in init_tis() Wei Yongjun
2013-04-26 14:28 ` [tpmdd-devel] " Kent Yoder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox