From: Peter Zijlstra Date: Wed, 9 May 2007 06:30:11 +0000 (+0200) Subject: sunrpc: fix crash in rpc_malloc() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ddce40df6e14dd474bbd9daa006dcc290dea6326;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git sunrpc: fix crash in rpc_malloc() While the comment says: * To prevent rpciod from hanging, this allocator never sleeps, * returning NULL if the request cannot be serviced immediately. The function does not actually check for NULL pointers being returned. Signed-off-by: Peter Zijlstra Signed-off-by: Trond Myklebust --- diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index b28a0b037f4f..b011eb625e49 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -767,6 +767,10 @@ void *rpc_malloc(struct rpc_task *task, size_t size) buf = mempool_alloc(rpc_buffer_mempool, gfp); else buf = kmalloc(size, gfp); + + if (!buf) + return NULL; + buf->len = size; dprintk("RPC: %5u allocated buffer of size %zu at %p\n", task->tk_pid, size, buf);