Skip to contentSkip to conversation

tpm_tis: fix missing platform_driver_unregister

PATCH In review Libo Chen 2 participants 2 messages May 2, 2013 TPM device driver

lore
Share & tools
lore

Libo Chen

author
#0 lore raw

PATCH 1/1 tpm_tis: fix missing platform_driver_unregister

Add missing unregister tis_drv after register pdev fail

---
 drivers/char/tpm/tpm_tis.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_tis.c +5 -2
index 8a41b6b..d5b0af4 100644
@@ -884,8 +884,11 @@ 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);
+	pdev = platform_device_register_simple("tpm_tis", -1, NULL, 0);
+	if (IS_ERR(pdev) {
+	    platform_driver_unregister(&tis_drv);
+	    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);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 4 lines · Libo Chen

Add missing unregister tis_drv after register pdev fail

Hi Libo - thanks for the contribution, but I got an similar patch
last week from Wei Yongjun. Its staged over here [1] and will be pushed soon.

Thanks,
Kent

[1] git://github.com/shpedoikal/linux.git tpmdd-04-26-13

Quoted 25 lines
---
 drivers/char/tpm/tpm_tis.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_tis.c +5 -2
index 8a41b6b..d5b0af4 100644
@@ -884,8 +884,11 @@ 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);
+	pdev = platform_device_register_simple("tpm_tis", -1, NULL, 0);
+	if (IS_ERR(pdev) {
+	    platform_driver_unregister(&tis_drv);
+	    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);
Signature · 1 line
1.7.1