Search Linux Wireless

[PATCH] NFC: nfcsim: fix the error handle in nfcsim_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>

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

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

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;
 }

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




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux