Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2692887rdb; Mon, 4 Dec 2023 05:10:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHP1tJNe0cdOlKLF/C7KO0JGoEDFa3w/CPWhT2EMPgK8XFGHcbWztIWqDstGgTHV+BM6FZi X-Received: by 2002:a05:6a00:22c6:b0:6ce:2731:c24f with SMTP id f6-20020a056a0022c600b006ce2731c24fmr1826493pfj.62.1701695404969; Mon, 04 Dec 2023 05:10:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701695404; cv=pass; d=google.com; s=arc-20160816; b=r0PGufowYwQYEELCBwgmAgtkzpzl8HuDMsR6P8VDFcAEYOIVdIpZJ8rAjUcQNrES+o +AubeuPbHGh3AsAL4r8zvmIX4xBz11wG54mveEKkzWAg9OhfHQTDEsOyaH0yl9tpkzT9 SJm8WivMHog3hAxjfDW+OTUhsbz88R4YTLWwxJQkqDeKPzqA85YHbtiCOLA7wuONrLND pkeBDh/4GtfL3xHN73CN7QJbTt/UZ0ftCnAScBey69HjKrASbY+1Ujv+oz1LZueaNNXv MdW4ECIxjDdNMBEUK3fhmNthPi30HUYtdrrdvUhZ+JRxyW3/uS56h7zelfd1eVJZGhpI jAiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hsnJ/KNlUs6XiyX2XlbfSpC3bHgmAF/BmM03d8xcwm0=; fh=RACn3Dz57j2O2Diwusdo+qDZ4fbRHVAux3E9Xar2zXI=; b=fz0RjUBFJuYGSQi/MWbhsORHxM4VK1RCTE+LoFT97npG/Lq8FikFSOrOEXGXIAygii HEi5Y9NbzSxRmlozMN8njY3gTchdW5IDCes6fgJ02G2TAsfmR7sou7Rzh/FjpDfonvdm LTHBCZEpXEdQ0RM6KRfIwOSbxoph6uKOapWrgbaX6ewJhONWQSebNOkqwPQ0uGbQ0xeJ djtR4XRYrdVqVTOArjj9Ra200KMn0RkkRYrgMIIe4tJ/Dvj+rzKCSN+3K0s+NVD+HQvu HZ6aop4mf/rTYHkkIVJacLgnBPvTdbXO+ncwHAPfGK51CF++TdQVReGSvhrIBSWJOflY EIKQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=fZFzcVqI; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j23-20020a63cf17000000b005c1b30b1b65si7662140pgg.648.2023.12.04.05.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 05:10:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=fZFzcVqI; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9598C805BCB2; Mon, 4 Dec 2023 05:09:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344287AbjLDNJ0 (ORCPT + 99 others); Mon, 4 Dec 2023 08:09:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235479AbjLDNJE (ORCPT ); Mon, 4 Dec 2023 08:09:04 -0500 Received: from sender-of-o51.zoho.in (sender-of-o51.zoho.in [103.117.158.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63B8FD6C; Mon, 4 Dec 2023 05:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701695310; cv=none; d=zohomail.in; s=zohoarc; b=KYKagfJwLJR/l2o8XdfQVvnTVoHBVbs/XFi1NE+ZFOzvPe9C3MeySQ6dsR7fuVze0enMACOpYdyse/VXY4TQOpztCd15R/HQt1dFpQo+0PIaRIxYhokDzi8H+w1lZpMeLsUZuZa3OirrMlDF+P5attVlRK71URPWgknHGqceuo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1701695310; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=hsnJ/KNlUs6XiyX2XlbfSpC3bHgmAF/BmM03d8xcwm0=; b=JD6UklVpZawlW1B9bazsFAdMttK/iEEh6W47YGXECq1gfQzXSDbz1EBzeCpM4FEi1z8o5Fa4P3EEhV/F+7RmIzy+b8eVYQphWBZZfcHGX8CvAb3kuIsvfL2LT/a2Mps3WTcwiz8MsVO/k/K52uxBmGW9nBnB7aUjljZLjLgLoaA= ARC-Authentication-Results: i=1; mx.zohomail.in; dkim=pass header.i=siddh.me; spf=pass smtp.mailfrom=code@siddh.me; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1701695310; s=zmail; d=siddh.me; i=code@siddh.me; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=hsnJ/KNlUs6XiyX2XlbfSpC3bHgmAF/BmM03d8xcwm0=; b=fZFzcVqId17iVSznukaO7vQYfftfVedXOqu0E3Xx9IHvtMr1JZUQVWuFZBWeRZwc JDm8i+f3I+w0UvjU6WCKAjd/Kv5aHQMZ1sSRBM3uAqdnv+VSNFM2Ba+MpSsrPPRgSEM PlFcAHRQGxUy4LMsKZ+VcWT4Z4zOv06xCvGfCt/M= Received: from kampyooter.. (223.229.148.242 [223.229.148.242]) by mx.zoho.in with SMTPS id 1701695308912849.1027651405482; Mon, 4 Dec 2023 18:38:28 +0530 (IST) From: Siddh Raman Pant To: Krzysztof Kozlowski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Suman Ghosh Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 2/2] nfc: Do not send datagram if socket state isn't LLCP_BOUND Date: Mon, 4 Dec 2023 18:38:22 +0530 Message-ID: <727e1ff5df5e8d36e19b25155b1555ed3fd0cdfe.1701627492.git.code@siddh.me> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 04 Dec 2023 05:09:56 -0800 (PST) As we know we cannot send the datagram (state can be set to LLCP_CLOSED by nfc_llcp_socket_release()), there is no need to proceed further. Thus, bail out early from llcp_sock_sendmsg(). Signed-off-by: Siddh Raman Pant Reviewed-by: Krzysztof Kozlowski --- net/nfc/llcp_sock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 645677f84dba..819157bbb5a2 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -796,6 +796,11 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg, } if (sk->sk_type == SOCK_DGRAM) { + if (sk->sk_state != LLCP_BOUND) { + release_sock(sk); + return -ENOTCONN; + } + DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, addr, msg->msg_name); -- 2.42.0