Skip to contentSkip to conversation

sunrpc: fix crash in rpc_malloc()

PATCH New Peter Zijlstra 1 participant 1 message May 9, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 net/sunrpc/sched.c |    4 ++++
 1 file changed, 4 insertions(+)
net/sunrpc/sched.c +4 -0
Index: 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);