]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
slub: fix possible NULL pointer dereference
authorCyrill Gorcunov <gorcunov@gmail.com>
Sun, 2 Mar 2008 20:28:24 +0000 (23:28 +0300)
committerChristoph Lameter <clameter@sgi.com>
Mon, 3 Mar 2008 20:22:32 +0000 (12:22 -0800)
This patch fix possible NULL pointer dereference if kzalloc
failed. To be able to return proper error code the function
return type is changed to ssize_t (according to callees and
sysfs definitions).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
mm/slub.c

index ecacacdce9d7050faa2598e49d1e2992dc70507d..0863fd38a5ce06a87392f5ba753606a516a5d262 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3564,8 +3564,8 @@ enum slab_stat_type {
 #define SO_CPU         (1 << SL_CPU)
 #define SO_OBJECTS     (1 << SL_OBJECTS)
 
-static unsigned long show_slab_objects(struct kmem_cache *s,
-                       char *buf, unsigned long flags)
+static ssize_t show_slab_objects(struct kmem_cache *s,
+                           char *buf, unsigned long flags)
 {
        unsigned long total = 0;
        int cpu;
@@ -3575,6 +3575,8 @@ static unsigned long show_slab_objects(struct kmem_cache *s,
        unsigned long *per_cpu;
 
        nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
+       if (!nodes)
+               return -ENOMEM;
        per_cpu = nodes + nr_node_ids;
 
        for_each_possible_cpu(cpu) {