diff mbox

NFC: nfcsim: fix the error handle in nfcsim_init()

Message ID CAPgLHd-1S=MSjOeW3+SQyFW_W9JuNSxgD1YDWEyF_aOtU4BFeQ@mail.gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Wei Yongjun Sept. 23, 2013, 9:56 a.m. UTC
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Add the missing unregister/free NFC device and destroy_workqueue()
before return in the error handling case.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/nfc/nfcsim.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c
index 9a53f13..a4a2286 100644
--- a/drivers/nfc/nfcsim.c
+++ b/drivers/nfc/nfcsim.c
@@ -497,15 +497,13 @@  static int __init nfcsim_init(void)
 	dev0 = nfcsim_init_dev();
 	if (IS_ERR(dev0)) {
 		rc = PTR_ERR(dev0);
-		goto exit;
+		goto exit_init_dev0;
 	}
 
 	dev1 = nfcsim_init_dev();
 	if (IS_ERR(dev1)) {
-		kfree(dev0);
-
 		rc = PTR_ERR(dev1);
-		goto exit;
+		goto exit_init_dev1;
 	}
 
 	dev0->peer_dev = dev1;
@@ -513,11 +511,14 @@  static int __init nfcsim_init(void)
 
 	pr_debug("NFCsim " NFCSIM_VERSION " initialized\n");
 
-	rc = 0;
+	return 0;
+
+exit_init_dev1:
+	nfcsim_free_device(dev0);
+exit_init_dev0:
+	destroy_workqueue(wq);
 exit:
-	if (rc)
-		pr_err("Failed to initialize nfcsim driver (%d)\n",
-		       rc);
+	pr_err("Failed to initialize nfcsim driver (%d)\n", rc);
 
 	return rc;
 }