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