[PATCH] sunrpc: fix crash in rpc_malloc()

From: Peter Zijlstra
Date: Wed May 09 2007 - 02:30:45 EST



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 <a.p.zijlstra@xxxxxxxxx>
---
net/sunrpc/sched.c | 4 ++++
1 file changed, 4 insertions(+)

Index: linux-2.6-git/net/sunrpc/sched.c
===================================================================
--- linux-2.6-git.orig/net/sunrpc/sched.c
+++ linux-2.6-git/net/sunrpc/sched.c
@@ -762,6 +762,10 @@ void *rpc_malloc(struct rpc_task *task,
buf = mempool_alloc(rpc_buffer_mempool, gfp);
else
buf = kmalloc(size, gfp);
+
+ if (!buf)
+ return NULL;
+
*buf = size;
dprintk("RPC: %5u allocated buffer of size %zu at %p\n",
task->tk_pid, size, buf);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/