diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2008-03-02 23:28:24 +0300 |
---|---|---|
committer | Christoph Lameter <clameter@sgi.com> | 2008-03-03 12:22:32 -0800 |
commit | 62e5c4b4d6351707346695fd9e151b6cda85cbe1 (patch) | |
tree | 66a8e4a842d4bcd2f87e28bb2faac19e75e355b3 | |
parent | f619cfe1bda809a97c407f4c723eb3235ecd64e5 (diff) | |
download | op-kernel-dev-62e5c4b4d6351707346695fd9e151b6cda85cbe1.zip op-kernel-dev-62e5c4b4d6351707346695fd9e151b6cda85cbe1.tar.gz |
slub: fix possible NULL pointer dereference
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>
-rw-r--r-- | mm/slub.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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) { |