linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slub: fix possible NULL pointer dereference
@ 2008-03-02 20:28 Cyrill Gorcunov
  2008-03-02 20:48 ` Pekka Enberg
  0 siblings, 1 reply; 3+ messages in thread
From: Cyrill Gorcunov @ 2008-03-02 20:28 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: LKML, Peter Zijlstra, Rik van Riel, Andrew Morton

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>
---

Index: linux-2.6.git/mm/slub.c
===================================================================
--- linux-2.6.git.orig/mm/slub.c	2008-03-02 22:53:27.000000000 +0300
+++ linux-2.6.git/mm/slub.c	2008-03-02 23:02:27.000000000 +0300
@@ -3591,8 +3591,8 @@ enum slab_stat_type {
 #define SO_CPU		(1 << SL_CPU)
 #define SO_OBJECTS	(1 << SL_OBJECTS)
 
-static unsigned long slab_objects(struct kmem_cache *s,
-			char *buf, unsigned long flags)
+static ssize_t slab_objects(struct kmem_cache *s,
+			    char *buf, unsigned long flags)
 {
 	unsigned long total = 0;
 	int cpu;
@@ -3602,6 +3602,8 @@ static unsigned long slab_objects(struct
 	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) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] slub: fix possible NULL pointer dereference
  2008-03-02 20:28 [PATCH] slub: fix possible NULL pointer dereference Cyrill Gorcunov
@ 2008-03-02 20:48 ` Pekka Enberg
  2008-03-02 21:30   ` Cyrill Gorcunov
  0 siblings, 1 reply; 3+ messages in thread
From: Pekka Enberg @ 2008-03-02 20:48 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Christoph Lameter, LKML, Peter Zijlstra, Rik van Riel, Andrew Morton

On Sun, Mar 2, 2008 at 10:28 PM, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> 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>

Looks good to me.

Reviewed-by: Pekka Enberg <penberg@cs.helsinki.fi>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] slub: fix possible NULL pointer dereference
  2008-03-02 20:48 ` Pekka Enberg
@ 2008-03-02 21:30   ` Cyrill Gorcunov
  0 siblings, 0 replies; 3+ messages in thread
From: Cyrill Gorcunov @ 2008-03-02 21:30 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: Christoph Lameter, LKML, Peter Zijlstra, Rik van Riel, Andrew Morton

Thanks for review, Pekka, and sorry for not cc'ed you on initial
submittion (just missed :(

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-02 21:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-02 20:28 [PATCH] slub: fix possible NULL pointer dereference Cyrill Gorcunov
2008-03-02 20:48 ` Pekka Enberg
2008-03-02 21:30   ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).