add Signed-off-by for patches
[linux-2.6.22.y-op-patches.git] / queue-2.6.22.y / slub-fix-possible-NULL-pointer-dereference.patch
blobd28a7116975a790544024cddf4b589ed4e640b6b
1 From 07ebc960d0bfb49bb5e1287c86bb3b9e4b77b043 Mon Sep 17 00:00:00 2001
2 From: Oliver Pinter <oliver.pntr@gmail.com>
3 Date: Tue, 4 Mar 2008 17:49:04 +0100
4 Subject: [PATCH] backport: slub: fix possible NULL pointer dereference
6 mainline: 62e5c4b4d6351707346695fd9e151b6cda85cbe1
7 -->8--
8 slub: fix possible NULL pointer dereference
10 This patch fix possible NULL pointer dereference if kzalloc
11 failed. To be able to return proper error code the function
12 return type is changed to ssize_t (according to callees and
13 sysfs definitions).
15 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
16 Signed-off-by: Christoph Lameter <clameter@sgi.com>
17 --8<--
19 Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com>
21 diff --git a/mm/slub.c b/mm/slub.c
22 index 648f2c7..e484f64 100644
23 --- a/mm/slub.c
24 +++ b/mm/slub.c
25 @@ -1,5 +1,5 @@
27 - * SLUB: A slab allocator that limits cache line use instead of queuing
28 + * SLUB: A slab ellocator that limits cache linenuse instead of queuing
29 * objects in per cpu and per node lists.
31 * The allocator synchronizes using per slab locks and only
32 @@ -3073,7 +3073,7 @@ enum slab_stat_type {
33 #define SO_CPU (1 << SL_CPU)
34 #define SO_OBJECTS (1 << SL_OBJECTS)
36 -static unsigned long slab_objects(struct kmem_cache *s,
37 +static ssize_t long slab_objects(struct kmem_cache *s,
38 char *buf, unsigned long flags)
40 unsigned long total = 0;
41 @@ -3084,6 +3084,8 @@ static unsigned long slab_objects(struct kmem_cache *s,
42 unsigned long *per_cpu;
44 nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
45 + if (!nodes)
46 + return -ENOMEM;
47 per_cpu = nodes + nr_node_ids;
49 for_each_possible_cpu(cpu) {