diff options
author | Aditya Pakki <pakki001@umn.edu> | 2019-03-19 04:19:44 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-03-19 21:48:07 +0100 |
commit | d7737d4257459ca8921ff911c88937be1a11ea9d (patch) | |
tree | 5f62be7d6a6c5bcd8da3a405825e6bab6159c1ee /net | |
parent | net-sysfs: call dev_hold if kobject_init_and_add success (diff) | |
download | linux-d7737d4257459ca8921ff911c88937be1a11ea9d.tar.xz linux-d7737d4257459ca8921ff911c88937be1a11ea9d.zip |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/nfc/llcp_sock.c | 9 |
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); |