flex_array: fix the panic when calling flex_array_alloc() without __GFP_ZERO

Previous thread: kernel/sys.c: fix compat uname machine by Linux Kernel Mailing List on Saturday, April 24, 2010 - 3:59 pm. (1 message)

Next thread: mtd: fix Orion NAND driver compilation with ARM OABI by Linux Kernel Mailing List on Saturday, April 24, 2010 - 3:59 pm. (1 message)
From: Linux Kernel Mailing List
Date: Saturday, April 24, 2010 - 3:59 pm

Gitweb:     http://git.kernel.org/linus/e59464c735db19619cde2aa331609adb02005f5b
Commit:     e59464c735db19619cde2aa331609adb02005f5b
Parent:     46da27664887fb95cedba53eafcf876de812c8c1
Author:     Changli Gao <xiaosuo@gmail.com>
AuthorDate: Fri Apr 23 13:17:45 2010 -0400
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Sat Apr 24 11:31:24 2010 -0700

    flex_array: fix the panic when calling flex_array_alloc() without __GFP_ZERO
    
    memset() is called with the wrong address and the kernel panics.
    
    Signed-off-by: Changli Gao <xiaosuo@gmail.com>
    Cc: Patrick McHardy <kaber@trash.net>
    Acked-by: David Rientjes <rientjes@google.com>
    Cc: <stable@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 lib/flex_array.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/flex_array.c b/lib/flex_array.c
index 66eef2e..41b1804 100644
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -99,7 +99,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
 	ret->element_size = element_size;
 	ret->total_nr_elements = total;
 	if (elements_fit_in_base(ret) && !(flags & __GFP_ZERO))
-		memset(ret->parts[0], FLEX_ARRAY_FREE,
+		memset(&ret->parts[0], FLEX_ARRAY_FREE,
 						FLEX_ARRAY_BASE_BYTES_LEFT);
 	return ret;
 }
--

Previous thread: kernel/sys.c: fix compat uname machine by Linux Kernel Mailing List on Saturday, April 24, 2010 - 3:59 pm. (1 message)

Next thread: mtd: fix Orion NAND driver compilation with ARM OABI by Linux Kernel Mailing List on Saturday, April 24, 2010 - 3:59 pm. (1 message)