Skip to content

Commit

Permalink
slub: fix possible NULL pointer dereference
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Christoph Lameter <[email protected]>
  • Loading branch information
cyrillos authored and Christoph Lameter committed Mar 3, 2008
1 parent f619cfe commit 62e5c4b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 62e5c4b

Please sign in to comment.