From patchwork Wed Mar 2 19:25:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12766626 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DDF5C433FE for ; Wed, 2 Mar 2022 19:25:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238656AbiCBT0O (ORCPT ); Wed, 2 Mar 2022 14:26:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238002AbiCBT0N (ORCPT ); Wed, 2 Mar 2022 14:26:13 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDB4DC1175 for ; Wed, 2 Mar 2022 11:25:29 -0800 (PST) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id AA48E3F60F for ; Wed, 2 Mar 2022 19:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1646249128; bh=KE7cA2DH2YKQP2Gc57E040M9nuLXTd4XcLilkBUwOrw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I41jrS7wEjcSy0G+jxzxKf/L+uALLOGTdGHRJzb5RCJJe5LwHrFcQ2M5PIVw2/UMT QN0WsJUKJ0yitn7w9xHDW2lNrasO9gSdNhfNK6RAabJcTB62x0Z2zYYbytpykONp/E eX74Plj5CFuJEC/vAcJUK08zX0CXGqnXrdZZcIIzGJjOquT0smIxEi1IsggbfL9uQZ l7zh3B3VyeO+5WOWzO9UjMpCDvpIyus/Y8MVF1nxWPEN1eWJD0Vm8Kgm/yXyYowsde BJP9P+5MQwjmcddNaGX5XbjoSOgwbvRpr67t8QKKqfYv3YG2zEyk4W5cWmlNpNlRDI m12S34JOgu6sA== Received: by mail-ed1-f70.google.com with SMTP id cm27-20020a0564020c9b00b004137effc24bso1548143edb.10 for ; Wed, 02 Mar 2022 11:25:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KE7cA2DH2YKQP2Gc57E040M9nuLXTd4XcLilkBUwOrw=; b=oXKs3eP863cBvH7pcqnc4MAH5uEccvley5fePnEu+qtiC5haSQXssG4BmYwAaJxYCP 3feOpc+9q329gF42CLRknjqiEWhp9fvUwq1xtljUQb0oR4ODS2KNzPNGVaSaTXPLWu3Z 7ttbpBeiIhu6tkdp1VD4RQxcAQLFuYHt9jnr9M8ESNGTD0yHE4yxvAhU0WMUXAD7Sb/G eKMtHbl49N2YydJXCdZ4wKsE7Mq07ESoP6c7pzSL4XFH7/d5xi2siDx4Y/dH7x55Xpnx of6d6MGmwxOT9axgaMDfL1tMeND4bCUZGLqldM01CH228Ko6YKv5DpJjxTwxKIvAFUrl QLrw== X-Gm-Message-State: AOAM532qTcgpJ2Xz3pHM/Ru1W8QjzjFclF7pBl9ROsWUXHVAbemhYiS0 LEqhPVhsFF3cypyPxzj/2ee5HluqT+PS0gMY/utLvgx20r33XvCHox/895exP3Ck8wusqXwiLh/ ZuJm7OcRABiEEWBV/Qc01S2TjAQsdZMsUqA== X-Received: by 2002:a05:6402:369c:b0:413:2bc0:3f00 with SMTP id ej28-20020a056402369c00b004132bc03f00mr30801303edb.126.1646249128345; Wed, 02 Mar 2022 11:25:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzj6ncNvbB8cHRaUtjFkSKVI4lc6ShTlpArR4gywnj3ywk9IVqiotnQYISrRs1enqnteey6vg== X-Received: by 2002:a05:6402:369c:b0:413:2bc0:3f00 with SMTP id ej28-20020a056402369c00b004132bc03f00mr30801289edb.126.1646249128190; Wed, 02 Mar 2022 11:25:28 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id i14-20020a50cfce000000b00415b0730921sm1482765edk.42.2022.03.02.11.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 11:25:27 -0800 (PST) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , "David S. Miller" , Jakub Kicinski , linux-nfc@lists.01.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v2 1/6] nfc: llcp: nullify llcp_sock->dev on connect() error paths Date: Wed, 2 Mar 2022 20:25:18 +0100 Message-Id: <20220302192523.57444-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> References: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Nullify the llcp_sock->dev on llcp_sock_connect() error paths, symmetrically to the code llcp_sock_bind(). The non-NULL value of llcp_sock->dev is used in a few places to check whether the socket is still valid. There was no particular issue observed with missing NULL assignment in connect() error path, however a similar case - in the bind() error path - was triggereable. That one was fixed in commit 4ac06a1e013c ("nfc: fix NULL ptr dereference in llcp_sock_getname() after failed connect"), so the change here seems logical as well. Signed-off-by: Krzysztof Kozlowski --- net/nfc/llcp_sock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 0b93a17b9f11..e92440c0c4c7 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -764,6 +764,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, llcp_sock->local = NULL; put_dev: + llcp_sock->dev = NULL; nfc_put_device(dev); error: From patchwork Wed Mar 2 19:25:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12766627 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96DD1C433FE for ; Wed, 2 Mar 2022 19:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239724AbiCBT0T (ORCPT ); Wed, 2 Mar 2022 14:26:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238866AbiCBT0Q (ORCPT ); Wed, 2 Mar 2022 14:26:16 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DDEEC12C8 for ; Wed, 2 Mar 2022 11:25:32 -0800 (PST) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 8263D3F1CB for ; Wed, 2 Mar 2022 19:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1646249130; bh=ePWS8huBNB8mOLwzP5l9zhhnqwr/R2aV/N6dfRb+pkA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OqDB+l+JRV4MPEmDj4lf32cqG+Pt9SxR6kg7Ds+fid5NhbPhKD2YmaOcgycudK/jb AHMMF+l7d1/ic2htSTd8NfnotJGKiyLYH5GDXu29JSrNsoJxIEbaW5IbfoHoQ08+s0 Iw+ZvwLnEijCMPmyuSp6qyXE6dsBNVsrxCiCNUCd+EseiO9/b491j39JmkA7ohEmp8 y2XvzR+0ebxKudBRT87KoIvZD3RAgT9Bz7LEXfwoUsTfP+OKVVV+T4brfWKceAsdIT ROCqOZOebBsUTko+zdZ3rEymQl8VUdMsw3qZtnuK0Tw1sBHFX8S/9bQww2u/5bk5Z3 2XiDAZLP9bk5w== Received: by mail-ed1-f70.google.com with SMTP id o20-20020aa7dd54000000b00413bc19ad08so1552298edw.7 for ; Wed, 02 Mar 2022 11:25:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ePWS8huBNB8mOLwzP5l9zhhnqwr/R2aV/N6dfRb+pkA=; b=15MWlB6ExP7EOLk1KlhvWKgIDKqFI9F/oKnQwmmXJ0aesxBKd7YwsPzCYylS9jh+do h+ZY6wKpx0UWzSpxy/z4Xd+T7Hg56O2B6SL4M1TTHmkXwDm1kArM37f17tciPmhVehQr WL532JIdK0LH8RE4cyv8S0UctR+99e0V7Wj0YN9fXBC/B0RSo2gmSf5luO6CxKVoV1pX j0Haka+2POIYbfcXgpw+cAoPPPiesDMk8StxyvZiWkZHyXxm5QOAAbGku97mCBmub6vZ GLzIdDjsPJtvbGdFVVSC+M/wKcReUNe1BjRFQ12lVBbfNpPyfBkFK3fD4VrCJkN76rBs kYZw== X-Gm-Message-State: AOAM531D5SOICouqQh87r5Lua+rdGScSIXhtT4ydrv/87brW1ltk/g0w seVIv33oKeEbmIdc2l4mPBFoEzh80ZiK49VfFVmlQ3E70vj1nUshsWSOckfg8wwnkS0I9fMSqal 1dB0Xx784ExhdWuXPHp7bygtYV7yM/JJN3w== X-Received: by 2002:aa7:d706:0:b0:415:a00b:4ee with SMTP id t6-20020aa7d706000000b00415a00b04eemr7325272edq.373.1646249129875; Wed, 02 Mar 2022 11:25:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFEFY4wLULZr/eBfkoQpBWjtr5OGYAVw5KfG35wQ8ZmBORByJ1wBNLn5MUEWgSX4YDGpFhpg== X-Received: by 2002:aa7:d706:0:b0:415:a00b:4ee with SMTP id t6-20020aa7d706000000b00415a00b04eemr7325252edq.373.1646249129662; Wed, 02 Mar 2022 11:25:29 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id i14-20020a50cfce000000b00415b0730921sm1482765edk.42.2022.03.02.11.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 11:25:28 -0800 (PST) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , "David S. Miller" , Jakub Kicinski , linux-nfc@lists.01.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v2 2/6] nfc: llcp: simplify llcp_sock_connect() error paths Date: Wed, 2 Mar 2022 20:25:19 +0100 Message-Id: <20220302192523.57444-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> References: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The llcp_sock_connect() error paths were using a mixed way of central exit (goto) and cleanup Signed-off-by: Krzysztof Kozlowski --- net/nfc/llcp_sock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index e92440c0c4c7..fdf0856182c6 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -712,10 +712,8 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, llcp_sock->local = nfc_llcp_local_get(local); llcp_sock->ssap = nfc_llcp_get_local_ssap(local); if (llcp_sock->ssap == LLCP_SAP_MAX) { - nfc_llcp_local_put(llcp_sock->local); - llcp_sock->local = NULL; ret = -ENOMEM; - goto put_dev; + goto sock_llcp_put_local; } llcp_sock->reserved_ssap = llcp_sock->ssap; @@ -760,11 +758,13 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, sock_llcp_release: nfc_llcp_put_ssap(local, llcp_sock->ssap); + +sock_llcp_put_local: nfc_llcp_local_put(llcp_sock->local); llcp_sock->local = NULL; + llcp_sock->dev = NULL; put_dev: - llcp_sock->dev = NULL; nfc_put_device(dev); error: From patchwork Wed Mar 2 19:25:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12766628 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A5D0C433F5 for ; Wed, 2 Mar 2022 19:25:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239281AbiCBT0e (ORCPT ); Wed, 2 Mar 2022 14:26:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238968AbiCBT0S (ORCPT ); Wed, 2 Mar 2022 14:26:18 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 902A7C12CA for ; Wed, 2 Mar 2022 11:25:34 -0800 (PST) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 509133F60D for ; Wed, 2 Mar 2022 19:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1646249133; bh=XW443xLXNMd7fKnAwsj5MsweNUN/P9g1RwySZfWsL7A=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CoWC2CRVBw5eVtEJaGeO7G7K9OT1T57bup82Nx394K6Ru+mm25uq9SwpBnpyDPGzR GXEH4mSru/px83ABd44dGfLi4oPYWzys9X7M4TGgBWTkEAgvkuOrLHTk0ju3w3u1Qh JfOleiEZg9cCt5qvqRGXFKsqju7S+1oymCIp603Y+XdarJ7wbMqsXt7mL6W8wM9NWb N4d3JWxW6kWwXRE9tQFjUX43XKZ7Efod5Ir2SxhcOTAGd2pfnAScjwfjd9ych2BFeX +rDHH2ju3E4hYo7Qmq2Q+Djp0EX6ZtFdgQba7EVC52LVVtXY3xvFcj4RQs9l6KWMb7 VbajMnazn6xmQ== Received: by mail-ej1-f71.google.com with SMTP id x2-20020a1709065ac200b006d9b316257fso1489668ejs.12 for ; Wed, 02 Mar 2022 11:25:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XW443xLXNMd7fKnAwsj5MsweNUN/P9g1RwySZfWsL7A=; b=YmHUnxiQkvxeYBkraOZLVHimzIolWSBFWR0PoxsOVpu14kYFuHxbOadVMeVwuO3NTX q0txU/VZJtnO/6ZTnmIidvvMnDQvgALRrjuSNh8KbCDyLQUgxpHjFixbbYSE+3VU00xl O/vs01CcabgWSo7SMABSJjxFP1nNw0YMgfnkuKgRVG3oyiwMlBMqViZ+I+5ct9d2hPOe /Q+u/EUhMTdlqQoaH/RKgz78gbHyQ1+kO36HwGkOfYIOExWgVsiXWhP9f8T7oh3m5Lsr HDsSeZ8cyEofFYoaah1AltWj/jl7K4en/C6LN1rAdqN1pMFqWBDzmZJlVEBceBj9E8fn vvLw== X-Gm-Message-State: AOAM530j+xJRdpz0L+sOb0smIUFeDtsW660mkF7a2bAEprAlbtQfaSAg wUNB32XE0OP/K9F6oXctH1KsHq6zXMkl6WS3q3fgDv4crmTlrWVeAqMzH7bcX6tYRec5bjbhWjq ZmpsyIIN6H6xtDpgYsGD1E8b2PlfB2M65xw== X-Received: by 2002:a17:906:2f97:b0:6ce:3ef6:94be with SMTP id w23-20020a1709062f9700b006ce3ef694bemr24638077eji.136.1646249131054; Wed, 02 Mar 2022 11:25:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsRBR/F3xyyehjGQgAe0B+0iZQvBRbcdylldzaOvYG3TOQZ1QZiyO7oXqhYToX9C8yGar/7A== X-Received: by 2002:a17:906:2f97:b0:6ce:3ef6:94be with SMTP id w23-20020a1709062f9700b006ce3ef694bemr24638059eji.136.1646249130844; Wed, 02 Mar 2022 11:25:30 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id i14-20020a50cfce000000b00415b0730921sm1482765edk.42.2022.03.02.11.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 11:25:30 -0800 (PST) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , "David S. Miller" , Jakub Kicinski , linux-nfc@lists.01.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v2 3/6] nfc: llcp: use centralized exiting of bind on errors Date: Wed, 2 Mar 2022 20:25:20 +0100 Message-Id: <20220302192523.57444-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> References: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Coding style encourages centralized exiting of functions, so rewrite llcp_sock_bind() error paths to use such pattern. This reduces the duplicated cleanup code, make success path visually shorter and also cleans up the errors in proper order (in reversed way from initialization). No functional impact expected. Signed-off-by: Krzysztof Kozlowski --- net/nfc/llcp_sock.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index fdf0856182c6..c9d5c427f035 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -108,21 +108,13 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) llcp_sock->service_name_len, GFP_KERNEL); if (!llcp_sock->service_name) { - nfc_llcp_local_put(llcp_sock->local); - llcp_sock->local = NULL; - llcp_sock->dev = NULL; ret = -ENOMEM; - goto put_dev; + goto sock_llcp_put_local; } llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock); if (llcp_sock->ssap == LLCP_SAP_MAX) { - nfc_llcp_local_put(llcp_sock->local); - llcp_sock->local = NULL; - kfree(llcp_sock->service_name); - llcp_sock->service_name = NULL; - llcp_sock->dev = NULL; ret = -EADDRINUSE; - goto put_dev; + goto free_service_name; } llcp_sock->reserved_ssap = llcp_sock->ssap; @@ -132,6 +124,19 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) pr_debug("Socket bound to SAP %d\n", llcp_sock->ssap); sk->sk_state = LLCP_BOUND; + nfc_put_device(dev); + release_sock(sk); + + return 0; + +free_service_name: + kfree(llcp_sock->service_name); + llcp_sock->service_name = NULL; + +sock_llcp_put_local: + nfc_llcp_local_put(llcp_sock->local); + llcp_sock->local = NULL; + llcp_sock->dev = NULL; put_dev: nfc_put_device(dev); From patchwork Wed Mar 2 19:25:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12766629 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E5C2C433EF for ; Wed, 2 Mar 2022 19:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238968AbiCBT0g (ORCPT ); Wed, 2 Mar 2022 14:26:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239565AbiCBT0S (ORCPT ); Wed, 2 Mar 2022 14:26:18 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA3E6C12E5 for ; Wed, 2 Mar 2022 11:25:34 -0800 (PST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8C8863F610 for ; Wed, 2 Mar 2022 19:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1646249133; bh=15HOmnObJXsVXxZJ5x/3DtxcDfRhMgZoa5zrHrITnNA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PKpplZhszbhJBuaAHLd6jCxXsHl9zjkiFVgZMG863un42zRgGs+HnE+bgl4xuzcBL M/jyqWnVP3jq+1AVzSiJJDUj+AhO+tlSDClcAr5uUMk3MFjIrKNbUgeEXObSon8Y4m XlJPOsPQ64VehcQUrlyOLx5jfdDXwyk6PHG10i22jT0noFffSsR+8IN+21xZIQtaB2 KLu/pMeYZj4zXM/kRjlAqUe3mynxwHjOAVGfRKG7q5J9MbCWpqyP4NIF22Ggaumn0X tCW/Y5WAIV9jMat707vXcHZNEYu5SCWhWblGe/wZXP6UeS3QlKqbw6dMVxinS6CO3D EZw84xfDQVjLw== Received: by mail-ej1-f70.google.com with SMTP id k16-20020a17090632d000b006ae1cdb0f07so1479434ejk.16 for ; Wed, 02 Mar 2022 11:25:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=15HOmnObJXsVXxZJ5x/3DtxcDfRhMgZoa5zrHrITnNA=; b=VGKlQX1bTskTYYxyDz+VwK6SX2qI6lSbC3tdSAGQmFBDYKZHIaePNYMzHa3m2gQfig e80mrDMjpQPKb3AH9uMszzWmq6nON+aG6sAOsC6racccodrwZoxnd8+ihx4wcXPF9miw m+loSvFIZge7bR8S1/tQI7ZWkC/ldpEEuhtF/6NL97P13b92WclYkq5oGgBI0CVRNWIB QP57Z4IarVPVSAhG48PC66naI3BOWDbQ/p7UXfgXKkBfkU3F6cB4ntFvozfzk2h/3NTS 9V73ocZEvOah/4PFTHMgMwCU3M+ZOiU/w7KQM+GNqe6JWjdKRbvLMAZG+uJsaUE4OWNA yOJg== X-Gm-Message-State: AOAM532P6f+aq2u8zK/omxgRhR1wlGyr4/sSj0fiOundb4sMY0IDpxee OcCEWbnKrmgVpnqbgWu6P8zYdJ+pTqp3cV2py3Fc7unt76KBOmy4GMcq+pYi3zDPU5qtA0485C9 S4aT0ythzVKc5dWsiog1/9vpydF54ihIQLw== X-Received: by 2002:a17:906:7751:b0:6ce:e3c:81a6 with SMTP id o17-20020a170906775100b006ce0e3c81a6mr23328452ejn.278.1646249132425; Wed, 02 Mar 2022 11:25:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoNWOZ7D/uCsO1FWpSxrBelZ9YFjgouGbue8Nl1lS/Y1LnCK8P6xOlohDZjyDgtT/p5sfpXA== X-Received: by 2002:a17:906:7751:b0:6ce:e3c:81a6 with SMTP id o17-20020a170906775100b006ce0e3c81a6mr23328438ejn.278.1646249132223; Wed, 02 Mar 2022 11:25:32 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id i14-20020a50cfce000000b00415b0730921sm1482765edk.42.2022.03.02.11.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 11:25:31 -0800 (PST) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , "David S. Miller" , Jakub Kicinski , linux-nfc@lists.01.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v2 4/6] nfc: llcp: use test_bit() Date: Wed, 2 Mar 2022 20:25:21 +0100 Message-Id: <20220302192523.57444-5-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> References: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use test_bit() instead of open-coding it, just like in other places touching the bitmap. Signed-off-by: Krzysztof Kozlowski --- net/nfc/llcp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c index 5ad5157aa9c5..b70d5042bf74 100644 --- a/net/nfc/llcp_core.c +++ b/net/nfc/llcp_core.c @@ -383,7 +383,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, pr_debug("WKS %d\n", ssap); /* This is a WKS, let's check if it's free */ - if (local->local_wks & BIT(ssap)) { + if (test_bit(ssap, &local->local_wks)) { mutex_unlock(&local->sdp_lock); return LLCP_SAP_MAX; From patchwork Wed Mar 2 19:25:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12766630 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BC0CC433EF for ; Wed, 2 Mar 2022 19:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241187AbiCBT0n (ORCPT ); Wed, 2 Mar 2022 14:26:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240398AbiCBT0c (ORCPT ); Wed, 2 Mar 2022 14:26:32 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF9AC1C8A for ; Wed, 2 Mar 2022 11:25:37 -0800 (PST) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id CEF743F5FB for ; Wed, 2 Mar 2022 19:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1646249135; bh=k1fbxXsPvGzkuFTuMvPObzXkHdaiukX+p5UqHJ6OWe0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PLYvzh17ADSUr1aiV9fmKtJnTScgSkeChmd0EwyYWDVsVOGK2x0qjqwdUFpCWG4bY nBwqr5G5JKiuSbIA+QesQqMuqXo2ShkdUUs7tbiX99nLDu2s6rFw5hxlExAkrThCLT g/quANbgfIVDbPsv2hY80x9kTyW0M/NgrsLTIOrmjghlfUShfYOWOxg1mx8arotdi7 PMmkiu4vlxPqd7Os5QHKlmRh+TFepSNxWO6guRJO4RHhA+7RGjWE7lIxiIYizvW10G VHZdxalRMno3kWtqbp/ldpy18pbnx2QQA72Qhyi0hoUkXfXGE8Iw+SO20AU/ZsbP/6 dSBZthGbUXIeQ== Received: by mail-ej1-f72.google.com with SMTP id x2-20020a1709065ac200b006d9b316257fso1489730ejs.12 for ; Wed, 02 Mar 2022 11:25:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k1fbxXsPvGzkuFTuMvPObzXkHdaiukX+p5UqHJ6OWe0=; b=J82XGEqkSk8sz8PhQzIuLTGyQb4mN1vguU9yhae1HG2EbGQjR2Pzpy9e8QYAws3vmV X1O2mEsnxPV5AvlZJ6zv1jvhOF6Vsrw8wf+4khK8W/1pLX02oLBt6Gki8qbbp50WtOge IB4cvnqT5q2AD1rqa5fF2eRKpOnBxmDAYaC2nigY1pUG65Inwt7sM1oz67ONAdmUC9U3 /Sv2d55Bmkl7k+mupiURxZ5SR8Ip3IHZoU5ixaac1tWnrs+7J5WYiPdeasGUa89ylyxX 2egpmqIS428GK+7JhLVCLjfCK1hlSzXm3XB3lOP+eo+/N1Ubrms3vOOwPL2eCkx7HQ8V JMiQ== X-Gm-Message-State: AOAM531H9CdnCX1ZIDjgfQF5LSN/ZVl3CRb69QDpjf8nb2S9KkEzkRFp C4LGwwgb0+CmMNMb9TLMLRbPPaTmd+KpE6uOzNs1iNm/OgipBZVMbUM/MJY9ZFprlJGdmv9abDj YOxk3T8ZwTTjTb45sNuBHSiqbv0k3fhUI9w== X-Received: by 2002:a17:906:18b2:b0:6d0:ee54:1add with SMTP id c18-20020a17090618b200b006d0ee541addmr24364521ejf.499.1646249134540; Wed, 02 Mar 2022 11:25:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQ2Yzk4nLxgx+97QWgQ7U+3qiE+VAfZ5ZxF3hEUaZA9fAEq5MaAHHtVajBlFnerH2vg2MVHw== X-Received: by 2002:a17:906:18b2:b0:6d0:ee54:1add with SMTP id c18-20020a17090618b200b006d0ee541addmr24364498ejf.499.1646249134294; Wed, 02 Mar 2022 11:25:34 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id i14-20020a50cfce000000b00415b0730921sm1482765edk.42.2022.03.02.11.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 11:25:33 -0800 (PST) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , "David S. Miller" , Jakub Kicinski , linux-nfc@lists.01.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v2 5/6] nfc: llcp: protect nfc_llcp_sock_unlink() calls Date: Wed, 2 Mar 2022 20:25:22 +0100 Message-Id: <20220302192523.57444-6-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> References: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org nfc_llcp_sock_link() is called in all paths (bind/connect) as a last action, still protected with lock_sock(). When cleaning up in llcp_sock_release(), call nfc_llcp_sock_unlink() in a mirrored way: earlier and still under the lock_sock(). Signed-off-by: Krzysztof Kozlowski --- net/nfc/llcp_sock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index c9d5c427f035..5c5705f5028b 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -631,6 +631,11 @@ static int llcp_sock_release(struct socket *sock) } } + if (sock->type == SOCK_RAW) + nfc_llcp_sock_unlink(&local->raw_sockets, sk); + else + nfc_llcp_sock_unlink(&local->sockets, sk); + if (llcp_sock->reserved_ssap < LLCP_SAP_MAX) nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap); @@ -643,11 +648,6 @@ static int llcp_sock_release(struct socket *sock) if (sk->sk_state == LLCP_DISCONNECTING) return err; - if (sock->type == SOCK_RAW) - nfc_llcp_sock_unlink(&local->raw_sockets, sk); - else - nfc_llcp_sock_unlink(&local->sockets, sk); - out: sock_orphan(sk); sock_put(sk); From patchwork Wed Mar 2 19:25:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12766631 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A866C433F5 for ; Wed, 2 Mar 2022 19:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240505AbiCBT0n (ORCPT ); Wed, 2 Mar 2022 14:26:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240439AbiCBT0c (ORCPT ); Wed, 2 Mar 2022 14:26:32 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A33FC1C8C for ; Wed, 2 Mar 2022 11:25:37 -0800 (PST) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 74B673F5F5 for ; Wed, 2 Mar 2022 19:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1646249136; bh=Mdsn7AT474MZc2MQVfRJDSMS8EOfClYXR9EYCiW/6uw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AUCDt5MsPe1PsjaSbSqC0wKPst/OHiR1mFTDwZknPsfCfDn916ACo+WiDg3LUbhvx dZd6/Pg+5i6ioIBg2Vmo0iSut117ANG+Bx5udlxo1Fw0w6W1mjq62wmXsYBLrTKZsD z0eNI7a/NpueBLdcZpxghkvOAZWXkVAFUIG1F6hQMpGwMl3lyjNRgAVQJHk7/AHJnj MOQGDbQZerf8yq2Zn55yQs0ZlhSFSBNHer/c9hTx7546G5clYCgRqQvb3O+8Q9xAzP sE1fNHrkqFBVneq139nTcS3cBXLdX7/8fviz3fsarIn9NQf7MA2I8k7b1hcH9fnw9/ IIWibeZL7mW+w== Received: by mail-ed1-f71.google.com with SMTP id j9-20020a056402238900b004128085d906so1509059eda.19 for ; Wed, 02 Mar 2022 11:25:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mdsn7AT474MZc2MQVfRJDSMS8EOfClYXR9EYCiW/6uw=; b=T1NzDtc/NMBVIBNWb6vLeBgDD11yAD6r2jSRmT1f+m1BMUF8fihlbd1RW5thuFBTHI 0hEsigShz5XSSJwqYIDK4WtR075yWd35UFpUJf8L1jXYrhDvP4Tc7p4ufBvpwqSe834M GGtlXCw52LO6Sy62aaEbafr+Gsi5aempXz7SoXpltXrJwN1pjkGMd+cGuTf2ch1xWWGN fwDQpg4mWDaN+4ViEplMMVKqoYMjtpKMcMo25VSFpLd3CFO3OLfkmS35ZXiaFSuQTqRk GueNlr4qK6PHMEBr64+byXgB+FW6VqHBsIq4sIynXi7DTD6uU0uf3tTgYigcAiWujDX5 UhwA== X-Gm-Message-State: AOAM533Lju2m8ecRhhE3wv3i3T/C8ZjIIaO7qG/xOrxQc00px8Jl2W66 dQOnJqDlCANBxHjDYa4ryNZSLd/1F4E6Zd3PoPd59B/CKrTyjh/pgLg1XIPiTP412UlsLCI5Cqg HTXgfBDk8dVKIrkvnT2IOi/axBUehIfEWGw== X-Received: by 2002:a17:906:714c:b0:6cf:4850:52cc with SMTP id z12-20020a170906714c00b006cf485052ccmr24550321ejj.319.1646249136076; Wed, 02 Mar 2022 11:25:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTh8qQiPVslsguc9Q0e99iiJ94AmhFY0BNCMiQLPiKFvI8B9dasw3D154XCQaRCiddESFGrA== X-Received: by 2002:a17:906:714c:b0:6cf:4850:52cc with SMTP id z12-20020a170906714c00b006cf485052ccmr24550313ejj.319.1646249135910; Wed, 02 Mar 2022 11:25:35 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id i14-20020a50cfce000000b00415b0730921sm1482765edk.42.2022.03.02.11.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 11:25:34 -0800 (PST) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , "David S. Miller" , Jakub Kicinski , linux-nfc@lists.01.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v2 6/6] nfc: llcp: Revert "NFC: Keep socket alive until the DISC PDU is actually sent" Date: Wed, 2 Mar 2022 20:25:23 +0100 Message-Id: <20220302192523.57444-7-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> References: <20220302192523.57444-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This reverts commit 17f7ae16aef1f58bc4af4c7a16b8778a91a30255. The commit brought a new socket state LLCP_DISCONNECTING, which was never set, only read, so socket could never set to such state. Remove the dead code. Signed-off-by: Krzysztof Kozlowski --- net/nfc/llcp.h | 1 - net/nfc/llcp_core.c | 7 ------- net/nfc/llcp_sock.c | 7 ------- 3 files changed, 15 deletions(-) diff --git a/net/nfc/llcp.h b/net/nfc/llcp.h index d49d4bf2e37c..c1d9be636933 100644 --- a/net/nfc/llcp.h +++ b/net/nfc/llcp.h @@ -6,7 +6,6 @@ enum llcp_state { LLCP_CONNECTED = 1, /* wait_for_packet() wants that */ LLCP_CONNECTING, - LLCP_DISCONNECTING, LLCP_CLOSED, LLCP_BOUND, LLCP_LISTEN, diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c index b70d5042bf74..3364caabef8b 100644 --- a/net/nfc/llcp_core.c +++ b/net/nfc/llcp_core.c @@ -737,13 +737,6 @@ static void nfc_llcp_tx_work(struct work_struct *work) print_hex_dump_debug("LLCP Tx: ", DUMP_PREFIX_OFFSET, 16, 1, skb->data, skb->len, true); - if (ptype == LLCP_PDU_DISC && sk != NULL && - sk->sk_state == LLCP_DISCONNECTING) { - nfc_llcp_sock_unlink(&local->sockets, sk); - sock_orphan(sk); - sock_put(sk); - } - if (ptype == LLCP_PDU_I) copy_skb = skb_copy(skb, GFP_ATOMIC); diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 5c5705f5028b..4ca35791c93b 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -641,13 +641,6 @@ static int llcp_sock_release(struct socket *sock) release_sock(sk); - /* Keep this sock alive and therefore do not remove it from the sockets - * list until the DISC PDU has been actually sent. Otherwise we would - * reply with DM PDUs before sending the DISC one. - */ - if (sk->sk_state == LLCP_DISCONNECTING) - return err; - out: sock_orphan(sk); sock_put(sk);