Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp103448rdb; Tue, 19 Dec 2023 10:30:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSl2Cp8oyD4OK67SmaKNmJeet3O5Ro1A158epb7bl2y5qOn6+dPt2t9D+MZ/wUeMg0YYNI X-Received: by 2002:a17:906:73cf:b0:a23:57ac:a974 with SMTP id n15-20020a17090673cf00b00a2357aca974mr1971483ejl.52.1703010654075; Tue, 19 Dec 2023 10:30:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703010654; cv=pass; d=google.com; s=arc-20160816; b=tEWlhMfCHEIm3H/ZZngMSLpuuGVSwYvbd3H+loMdbOSAjb6NSz8KrBEUxlKn8WIIkr vS/vOR7O9IyHtwBKLTalVrCA05UnxX5gOLcaQZjMzRnz2951C+sf+m6H2jrz9yr5yLdP P56QkuRwvtqGq6BVQ+PWudx73761hpAoTIG7XsfNkx4WLgHfhyR0/TVmXsx461wnnMhg 8Syag1iW0szwh7D/3qCX9ArvsO83iyUk783jeCMpMXXeSxGfsU1nnSPcqBRHIgtvdL8g q7v4mvXfPjNzZqIe5rYi79ogiyKutU3usdQelYvZhoCftrIwE43f7LE3oBCAU4tnxJf9 5gHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=872tkGPm7VUCxpgjJMERmpcep5wm35gG4ZP3R1Drljw=; fh=jRNF1o820nunFTFcGlj9FjVjB7ilggMA+a+y3yJrIks=; b=XffLhltonqjWLSPsFVbFnQv5T2rQWp2sZoZJuPr9WYQeDmY62ZgEmD3nNF3aSPf0bd MfdwzCVSnnne7+jACSxSB/W+czQM2zJWHM22KtW0tgi1dTiWW6qMy8tvZULAX8XfRaAx URdM2IVub8+cak5vo9x+hbcDwcOlxRH1rrW+SlCUWHOWfzLKOZNB7T9Z1EJQz05Yh8it 4VentwWd73tCWKwdjacxBr6GOdvY4nEqbQbjR/FzQM2UnChk7gN2tR71VSJafAHAt89y Wb/7qYpg89flyp/t1VsX3tqNNzfnZYkaU2Exvopy/K9h2U7FfsVKTLc4M40xPVrxbsyJ uBpQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=d3w5td7+; 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+bounces-5732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n13-20020a170906378d00b00a233fa4f832si2522011ejc.535.2023.12.19.10.30.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 10:30:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=d3w5td7+; 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+bounces-5732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AF8421F25929 for ; Tue, 19 Dec 2023 17:53:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE32139AC2; Tue, 19 Dec 2023 17:50:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=siddh.me header.i=code@siddh.me header.b="d3w5td7+" X-Original-To: linux-kernel@vger.kernel.org Received: from sender-of-o51.zoho.in (sender-of-o51.zoho.in [103.117.158.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7D6E374F8; Tue, 19 Dec 2023 17:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=siddh.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=siddh.me ARC-Seal: i=1; a=rsa-sha256; t=1703008193; cv=none; d=zohomail.in; s=zohoarc; b=O2lZZ9HwWZENrMMyZrM1Yzod/hHiK+jK7pDwdayn2m/RELjnaOQnoMBhLc8IgMYKPkp/gIlHxPLgIOZ4KmPkAVR/7tlVNneEy+hM1iKd8T4Osi57whn1bSuVC1f4zoc2OMSZ/G0LiBqOEJAOtx4j8NAvNsFbnsoupDURhzgLP5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1703008193; 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=872tkGPm7VUCxpgjJMERmpcep5wm35gG4ZP3R1Drljw=; b=RAmho9NtBqc8m36Qeb4liQdXtQa96J7exICe0g9G/LAGohQmSHMOq7impzN3sDPMcWQd2iuImnttjpLMgK27s0kTYvj34zoU7mZAl/gvF+mCIki+Z1umMeUvUmt0BcPiigMScbdTp0tfAwvGT47vijAHTqokNzmm7BXo/KMS1F4= 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=1703008193; 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=872tkGPm7VUCxpgjJMERmpcep5wm35gG4ZP3R1Drljw=; b=d3w5td7+zQt54GRVeCfbgqH/oeI7Y0/Kqr/EfxRXvdCSbwbJTYN0z51jFOGuQ3DI H+WpJKUkaIMo73xARw10HHgeCqQmna40+cEq7eCkGrH2l7dlq5pCdlaD4A3kptOOgna 5H5BRWJ2kwXXZN9Y9+zP8LcVOSbkCXJBYdTXw+9M= Received: from kampyooter.. (122.170.167.40 [122.170.167.40]) by mx.zoho.in with SMTPS id 1703008191467810.3177351858395; Tue, 19 Dec 2023 23:19:51 +0530 (IST) From: Siddh Raman Pant To: Krzysztof Kozlowski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Suman Ghosh Subject: [PATCH net-next v7 2/2] nfc: Do not send datagram if socket state isn't LLCP_BOUND Date: Tue, 19 Dec 2023 23:19:44 +0530 Message-ID: <0490c52b68c27730d9916ff22c917b4838c32af4.1702925869.git.code@siddh.me> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External 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 Reviewed-by: Suman Ghosh --- 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.43.0