summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Pakki <pakki001@umn.edu>2019-03-19 06:19:44 +0300
committerDavid S. Miller <davem@davemloft.net>2019-03-19 23:48:07 +0300
commitd7737d4257459ca8921ff911c88937be1a11ea9d (patch)
tree5f62be7d6a6c5bcd8da3a405825e6bab6159c1ee
parenta3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e (diff)
downloadlinux-d7737d4257459ca8921ff911c88937be1a11ea9d.tar.xz
nfc: Fix to check for kmemdup failure
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> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/nfc/llcp_sock.c9
1 files changed, 7 insertions, 2 deletions
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);