Skip to content

Commit

Permalink
nfc: fix error handling of nfc_proto_register()
Browse files Browse the repository at this point in the history
When nfc proto id is using, nfc_proto_register() return -EBUSY error
code, but forgot to unregister proto. Fix it by adding proto_unregister()
in the error handling case.

Fixes: c7fe3b5 ("NFC: add NFC socket family")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Link: https://lore.kernel.org/r/20211013034932.2833737-1-william.xuanziyang@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Ziyang Xuan authored and Jakub Kicinski committed Oct 14, 2021
1 parent 1f922d9 commit 0911ab3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/nfc/af_nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ int nfc_proto_register(const struct nfc_protocol *nfc_proto)
proto_tab[nfc_proto->id] = nfc_proto;
write_unlock(&proto_tab_lock);

if (rc)
proto_unregister(nfc_proto->proto);

return rc;
}
EXPORT_SYMBOL(nfc_proto_register);
Expand Down

0 comments on commit 0911ab3

Please sign in to comment.