Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62e5c4b4 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Christoph Lameter
Browse files

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: default avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
parent f619cfe1
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3564,7 +3564,7 @@ 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,
static ssize_t show_slab_objects(struct kmem_cache *s,
			    char *buf, unsigned long flags)
{
	unsigned long total = 0;
@@ -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) {