diff options
author | Ziyang Xuan <william.xuanziyang@huawei.com> | 2021-10-13 11:49:32 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-10-20 11:23:04 +0200 |
commit | 081d231e2aaf3f42fc56f49232c8abd3858ef5bc (patch) | |
tree | 62ce6c532433642f00484ef2989ba622ec118f93 | |
parent | a3999758c3b0de7a0d4ed240d546c1832da4ef1c (diff) | |
download | linux-stable-081d231e2aaf3f42fc56f49232c8abd3858ef5bc.tar.gz linux-stable-081d231e2aaf3f42fc56f49232c8abd3858ef5bc.tar.bz2 linux-stable-081d231e2aaf3f42fc56f49232c8abd3858ef5bc.zip |
nfc: fix error handling of nfc_proto_register()
commit 0911ab31896f0e908540746414a77dd63912748d upstream.
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: c7fe3b52c128 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/nfc/af_nfc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/nfc/af_nfc.c b/net/nfc/af_nfc.c index d3e594eb36d0..adf16ff007cc 100644 --- a/net/nfc/af_nfc.c +++ b/net/nfc/af_nfc.c @@ -72,6 +72,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); |