]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
SUNRPC: svc_tcp_sendmsg() should handle errors from xdr_alloc_bvec()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 7 Apr 2022 18:10:23 +0000 (14:10 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2022 19:01:07 +0000 (21:01 +0200)
[ Upstream commit b056fa070814897be32d83b079dbc311375588e7 ]

The allocation is done with GFP_KERNEL, but it could still fail in a low
memory situation.

Fixes: 4a85a6a3320b ("SUNRPC: Handle TCP socket sends with kernel_sendpage() again")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sunrpc/svcsock.c

index eba1714bf09ab33d0c00e734d702e4d326ac3831..6d5bb8bfed38b32ab80e64086d0c269cd2d491cc 100644 (file)
@@ -1091,7 +1091,9 @@ static int svc_tcp_sendmsg(struct socket *sock, struct msghdr *msg,
        int flags, ret;
 
        *sentp = 0;
-       xdr_alloc_bvec(xdr, GFP_KERNEL);
+       ret = xdr_alloc_bvec(xdr, GFP_KERNEL);
+       if (ret < 0)
+               return ret;
 
        msg->msg_flags = MSG_MORE;
        ret = kernel_sendmsg(sock, msg, &rm, 1, rm.iov_len);