diff mbox series

net: Fix to check for kmemdup failure

Message ID 20190319031944.18984-1-pakki001@umn.edu (mailing list archive)
State Deferred
Delegated to: Samuel Ortiz
Headers show
Series net: Fix to check for kmemdup failure | expand

Commit Message

Aditya Pakki March 19, 2019, 3:19 a.m. UTC
In case of kmemdup failure while setting the service name the patch
returns -ENOMEM upstream for processing.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 net/nfc/llcp_sock.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

David Miller March 19, 2019, 8:48 p.m. UTC | #1
From: Aditya Pakki <pakki001@umn.edu>
Date: Mon, 18 Mar 2019 22:19:44 -0500

> In case of kmemdup failure while setting the service name the patch
> returns -ENOMEM upstream for processing.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>

Applied.
diff mbox series

Patch

diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index ae296273ce3d..17dcd0b5eb32 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -726,6 +726,10 @@  static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
 	llcp_sock->service_name = kmemdup(addr->service_name,
 					  llcp_sock->service_name_len,
 					  GFP_KERNEL);
+	if (!llcp_sock->service_name) {
+		ret = -ENOMEM;
+		goto sock_llcp_release;
+	}
 
 	nfc_llcp_sock_link(&local->connecting_sockets, sk);
 
@@ -745,10 +749,11 @@  static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
 	return ret;
 
 sock_unlink:
-	nfc_llcp_put_ssap(local, llcp_sock->ssap);
-
 	nfc_llcp_sock_unlink(&local->connecting_sockets, sk);
 
+sock_llcp_release:
+	nfc_llcp_put_ssap(local, llcp_sock->ssap);
+
 put_dev:
 	nfc_put_device(dev);