Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3073455pxb; Tue, 12 Oct 2021 20:53:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzDdcoJqPTg8dd7BMgYDnnYf6JFZ36YLkLQzrPlVKqcclIgDsIc3CURdSUMg45T6XeIJzV X-Received: by 2002:a65:508a:: with SMTP id r10mr25724692pgp.96.1634097202119; Tue, 12 Oct 2021 20:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634097202; cv=none; d=google.com; s=arc-20160816; b=qKF7ddaTb/R10nzZbIGRNsFcFI1UrZJV5xqygKvLgm/gDes45/okFPZHGxg1MpS/3P JbnjQuIX4b5VMCIaSqNjZGFZ47mPdGOKcFbMxKTtH9ZrV0kEng8wRH2+QO3LLS9L0eIZ lj4dWSD+aWd2CtM9UQ/g5/2Ca3YBTPFS2mZnl0Yb3pURxndQcsq6AfpJUtcVM7dHlBC5 fsUJH/JbFIJchU8P65aUQJvmPuquzd4uELR2t8JOokGcrrGnLQRmgg08p8sCdxmTAOBj U7aUYPPtmVDjyI/e8L2kL0tsPjhReJCdnZeuW40KQRRjyoWySAYd2DqppX+IykvkRT3l Qt2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=o2/7VJFTUXc+K+zJVabP9IV8Jgqn4eJYV2zYDeCb3EA=; b=iE2RJtJgGGcxZCywM0ichiTbRyn9Z8JNxMJ8/Dp5EYbagdpTllHU0FYJArw8oL86mG 1TEXaM/2PxYu5bOYcGBDI8BmDHv0tmaUiHgAwYGUZ6X1vh9m/6MZIPP1i1vQJvupA2Ga 8nksTSGAoaBwdc7XY8knCbcMPIiZURySITumlCLlTXfwLAgnqjVv3KqkfvaKnApxBKes bA+FT3Telg5h+W28itgybi2kPKTlESQMMPgzRy4RgNAsRhrD/JzH9NxnPDwzbstDkfeY eGI5I91O0ezxBNlspJVBJW7LbDwjEEejrMv4AJh1YGUoy2Ea5IpkXFJXHAGRA3mKu56+ lxLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u185si16308422pfb.31.2021.10.12.20.53.08; Tue, 12 Oct 2021 20:53:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236992AbhJMDxD (ORCPT + 99 others); Tue, 12 Oct 2021 23:53:03 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:13730 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229717AbhJMDxA (ORCPT ); Tue, 12 Oct 2021 23:53:00 -0400 Received: from dggeml757-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HTdnW3xGKzWVR6; Wed, 13 Oct 2021 11:49:19 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by dggeml757-chm.china.huawei.com (10.1.199.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Wed, 13 Oct 2021 11:50:56 +0800 From: Ziyang Xuan To: CC: , , , Subject: [PATCH net] nfc: fix error handling of nfc_proto_register() Date: Wed, 13 Oct 2021 11:49:32 +0800 Message-ID: <20211013034932.2833737-1-william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggeml757-chm.china.huawei.com (10.1.199.137) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/nfc/af_nfc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/nfc/af_nfc.c b/net/nfc/af_nfc.c index 6024fad905ff..dda323e0a473 100644 --- a/net/nfc/af_nfc.c +++ b/net/nfc/af_nfc.c @@ -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); -- 2.25.1