Skip to contentSkip to conversation

nfc: Do not send datagram if socket state isn't LLCP_BOUND

PATCH New Sasha Levin 1 participant 2 messages Jan 8, 2024

Subsystems (4)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

PATCH 1/2 nfc: Do not send datagram if socket state isn't LLCP_BOUND

From: Siddh Raman Pant <[email protected]>

[ Upstream commit 6ec0d7527c4287369b52df3bcefd21a0c4fb2b7c ]

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().

---
 net/nfc/llcp_sock.c | 5 +++++
 1 file changed, 5 insertions(+)
net/nfc/llcp_sock.c +5 -0
index 605d7448c3de1..b27bb2e2486c2 100644
@@ -802,6 +802,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);
 
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH 2/2 ARM: sun9i: smp: fix return code check of of_property_match_string

From: Stefan Wahren <[email protected]>

[ Upstream commit 643fe70e7bcdcc9e2d96952f7fc2bab56385cce5 ]

of_property_match_string returns an int; either an index from 0 or greater if successful or negative on failure. Even it's very unlikely that the DT CPU node contains multiple enable-methods these checks should be fixed.

This patch was inspired by the work of Nick Desaulniers.

---
 arch/arm/mach-sunxi/mc_smp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-sunxi/mc_smp.c +2 -2
index ff173e67eed21..1fbc5b5a3cfe8 100644
@@ -801,14 +801,14 @@ static int __init sunxi_mc_smp_init(void)
 	for (i = 0; i < ARRAY_SIZE(sunxi_mc_smp_data); i++) {
 		ret = of_property_match_string(node, "enable-method",
 					       sunxi_mc_smp_data[i].enable_method);
-		if (!ret)
+		if (ret >= 0)
 			break;
 	}
 
 	is_a83t = sunxi_mc_smp_data[i].is_a83t;
 
 	of_node_put(node);
-	if (ret)
+	if (ret < 0)
 		return -ENODEV;
 
 	if (!sunxi_mc_smp_cpu_table_init())
Signature · 1 line
2.43.0