Received: by 2002:a05:7412:8d08:b0:f9:2d0a:d759 with SMTP id bj8csp123212rdb; Sun, 17 Dec 2023 05:12:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLyzVJKCyNvARu6gf3zQXLvPb2sJhoEjt4Or2m/cugKvb8aQel8gA5ni9PwpgrwkXy1Ukw X-Received: by 2002:a05:6e02:1d8b:b0:35d:78a2:c3d3 with SMTP id h11-20020a056e021d8b00b0035d78a2c3d3mr19854338ila.79.1702818734377; Sun, 17 Dec 2023 05:12:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702818734; cv=pass; d=google.com; s=arc-20160816; b=ie3xRQm7tY1E6kEAv3dT8eg5tDWNBX1ZRlhhZkvzXKMgaNZQdwUrG0ysUqDc5lcvmP oC+k7O+LaivRS0kvgMNFybaC7QV5CI8aksUFGKWLt3+In68quc6AzaBiCkYeN9tWfKI/ KKfjBSwBShL7vAx8UTkqr0sYHbRZP35IrkVtSZ3WEjggl8qs3uH4/N1yhpMR2wIxPFdb qo/T8jqRGvqdf4Wu3NNAxsOnlwwcJiIe7ZBrTnqnteZkUAlVcAwovYe9b31yJfgi61QZ BPkRrEEMS6/+saK9i+GMsKl8jIVBpaXdNg5Xqhl/hQ0WIkNswEPLma23lErdkUiMn61I rHew== 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=Scp3IrJnE67ltgIhAprfULm6HsQ/s5KxrhhmK7w7AQs=; fh=RACn3Dz57j2O2Diwusdo+qDZ4fbRHVAux3E9Xar2zXI=; b=tq405kh0gQjtiiGRepr4XkZcB21MvKQUu+uJbI7HfpxlzwYR6cDRUn5FfEqKFbC1UM hVGWg5LToVG54m1BLXmr1uqZaUTtpjRfGzCDZj/3CClucFEU5/z0iE1qxYwRiKwX3hO/ aiWPRD2gwEsWllSrSmifG9mCJzK+qOxEuE/Gf+swTCo/DiGGPFwAAnQPBWTKgfKf+Gey ZDQJkaTwgxdz/pz6dWlkFi9tw9G+gN7sq4i8Ui3x2xiLr7oZeC/HM08wD//hAGBURzlk WEzzpnqM5RebyjoyaGhLKywP6HOtN7RnnBUtYwPwM66mGkyDuqeOsLEHvGHjhm6Atuu+ uhDg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=jaJKRVZz; 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-2592-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2592-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q19-20020a62ae13000000b006be3c302801si15841454pff.397.2023.12.17.05.12.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:12:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2592-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=jaJKRVZz; 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-2592-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2592-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A9FCF282FEA for ; Sun, 17 Dec 2023 13:12:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8CC844387; Sun, 17 Dec 2023 13:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=siddh.me header.i=code@siddh.me header.b="jaJKRVZz" 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 981814317A; Sun, 17 Dec 2023 13:11:51 +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=1702818675; cv=none; d=zohomail.in; s=zohoarc; b=AQdENfINNapZlrC/EctTnMZUARzUjwqbKHHbdEEIS+PA/YJq9Kr7O1NZFI/0CjCG9HNKGuBKx6jj7a9S5baUa/ElWre7+dGz5AiN1iCDebo4hOAojZCx+c4WI458hKsH2utYDcwJXDkSFJR5GguCBcu3srbWSBPiG/tqzspomMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1702818675; 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=Scp3IrJnE67ltgIhAprfULm6HsQ/s5KxrhhmK7w7AQs=; b=RnMOfZmQGs6b+piHKyDlptYaeFtNUGn/VMBA0li+cpBYo4RoyAjFTb6QaFQ/QE19T2AAarLo69XjQ+A0AXp+8VOOEmZf25rvAYj4qOHEQBT/0N0cLZYhgcZ3YaxP/UGrKhg+q+PsXrZRIq747QSemHYzlChItQpMFHIXewCHScg= 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=1702818675; 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=Scp3IrJnE67ltgIhAprfULm6HsQ/s5KxrhhmK7w7AQs=; b=jaJKRVZzCRbtac7qltv2l3keyMs1H8djk4xukyoEvvldO4gHlQB+2ZaM8m4ybNSg IY+MFe+jnwoU0p74HFXy6VvahDRpCQIkXcLOYKKG0j/6XKcWVGbbxOkEU71OM3AgVSI OU/VVQH77liZRBQ1Vgt47cjBXciQUwM/8e9nkmLo= Received: from kampyooter.. (122.170.167.40 [122.170.167.40]) by mx.zoho.in with SMTPS id 1702818674595848.1274981870353; Sun, 17 Dec 2023 18:41:14 +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 v6 2/2] nfc: Do not send datagram if socket state isn't LLCP_BOUND Date: Sun, 17 Dec 2023 18:41:04 +0530 Message-ID: X-Mailer: git-send-email 2.42.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.42.0