From: Siddh Raman Pant <code@siddh.me>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] nfc: llcp_sock_sendmsg: Reformat code to make the smaller block indented
Date: Sun, 26 Nov 2023 01:56:19 +0530 [thread overview]
Message-ID: <f5e1fc8131923c50d08fa30eb7136f32ddafe37d.1700943019.git.code@siddh.me> (raw)
In-Reply-To: <cover.1700943019.git.code@siddh.me>
The block for datagram sending is a significantly bigger chunk of the
function compared to the other scenario.
Thus, put the significantly smaller block inside the if-block.
Signed-off-by: Siddh Raman Pant <code@siddh.me>
---
net/nfc/llcp_sock.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 603f2219b62f..3f1a39e54aa1 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -795,34 +795,32 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
return -ENODEV;
}
- if (sk->sk_type == SOCK_DGRAM) {
- if (sk->sk_state != LLCP_BOUND) {
- release_sock(sk);
- return -ENOTCONN;
- }
+ if (sk->sk_type != SOCK_DGRAM) {
+ release_sock(sk);
- DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, addr,
- msg->msg_name);
+ if (sk->sk_state != LLCP_CONNECTED)
+ return -ENOTCONN;
- if (msg->msg_namelen < sizeof(*addr)) {
- release_sock(sk);
- return -EINVAL;
- }
+ return nfc_llcp_send_i_frame(llcp_sock, msg, len);
+ }
+ if (sk->sk_state != LLCP_BOUND) {
release_sock(sk);
-
- return nfc_llcp_send_ui_frame(llcp_sock, addr->dsap, addr->ssap,
- msg, len);
+ return -ENOTCONN;
}
- if (sk->sk_state != LLCP_CONNECTED) {
+ DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, addr, msg->msg_name);
+
+ if (msg->msg_namelen < sizeof(*addr)) {
release_sock(sk);
- return -ENOTCONN;
+ return -EINVAL;
}
release_sock(sk);
- return nfc_llcp_send_i_frame(llcp_sock, msg, len);
+ return nfc_llcp_send_ui_frame(llcp_sock, addr->dsap, addr->ssap,
+ msg, len);
+
}
static int llcp_sock_recvmsg(struct socket *sock, struct msghdr *msg,
--
2.42.0
next prev parent reply other threads:[~2023-11-25 20:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-25 20:26 [PATCH 0/4] Fix UAF caused by racing datagram sending and freeing of nfc_dev Siddh Raman Pant
2023-11-25 20:26 ` [PATCH 1/4] nfc: Extract nfc_dev access from nfc_alloc_send_skb() into the callers Siddh Raman Pant
2023-11-27 10:10 ` Krzysztof Kozlowski
2023-12-02 13:31 ` Siddh Raman Pant
2023-11-25 20:26 ` [PATCH 2/4] nfc: Protect access to nfc_dev in an llcp_sock with a rwlock Siddh Raman Pant
2023-11-27 10:38 ` Krzysztof Kozlowski
2023-12-02 13:30 ` Siddh Raman Pant
2023-11-25 20:26 ` [PATCH 3/4] nfc: Do not send datagram if socket state isn't LLCP_BOUND Siddh Raman Pant
2023-11-27 10:54 ` Krzysztof Kozlowski
2023-11-25 20:26 ` Siddh Raman Pant [this message]
2023-11-27 10:57 ` [PATCH 4/4] nfc: llcp_sock_sendmsg: Reformat code to make the smaller block indented Krzysztof Kozlowski
2023-11-27 10:04 ` [PATCH 0/4] Fix UAF caused by racing datagram sending and freeing of nfc_dev Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f5e1fc8131923c50d08fa30eb7136f32ddafe37d.1700943019.git.code@siddh.me \
--to=code@siddh.me \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).