sunrpc: handle ENOMEM in rpcb_getport_async
authorJ. Bruce Fields <bfields@redhat.com>
Thu, 20 Dec 2018 15:35:11 +0000 (10:35 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Jan 2019 07:10:55 +0000 (08:10 +0100)
commit 81c88b18de1f11f70c97f28ced8d642c00bb3955 upstream.

If we ignore the error we'll hit a null dereference a little later.

Reported-by: syzbot+4b98281f2401ab849f4b@syzkaller.appspotmail.com
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sunrpc/rpcb_clnt.c

index 5b30603596d0c7c5c5a4d3e3ffdca259c65ba343..eafc78e063f1d89db197c9ddc6d6e2dedb6eb0b9 100644 (file)
@@ -770,6 +770,12 @@ void rpcb_getport_async(struct rpc_task *task)
        case RPCBVERS_3:
                map->r_netid = xprt->address_strings[RPC_DISPLAY_NETID];
                map->r_addr = rpc_sockaddr2uaddr(sap, GFP_ATOMIC);
+               if (!map->r_addr) {
+                       status = -ENOMEM;
+                       dprintk("RPC: %5u %s: no memory available\n",
+                               task->tk_pid, __func__);
+                       goto bailout_free_args;
+               }
                map->r_owner = "";
                break;
        case RPCBVERS_2:
@@ -792,6 +798,8 @@ void rpcb_getport_async(struct rpc_task *task)
        rpc_put_task(child);
        return;
 
+bailout_free_args:
+       kfree(map);
 bailout_release_client:
        rpc_release_client(rpcb_clnt);
 bailout_nofree: