include/linux/kfifo.h: fix INIT_KFIFO()
authorDavid Härdeman <david@hardeman.nu>
Tue, 6 Apr 2010 21:34:43 +0000 (14:34 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 7 Apr 2010 15:38:02 +0000 (08:38 -0700)
DECLARE_KFIFO creates a union with a struct kfifo and a buffer array with
size [size + sizeof(struct kfifo)].

INIT_KFIFO then sets the buffer pointer in struct kfifo to point to the
beginning of the buffer array which means that the first call to kfifo_in
will overwrite members of the struct kfifo.

Signed-off-by: David Härdeman <david@hardeman.nu>
Acked-by: Stefani Seibold <stefani@seibold.net>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/kfifo.h

index ece0b1c33816d414e79b7d6046d17230fe71bf28..e117b1aee69c76eb39a9e66e3e69f8718cf5d49f 100644 (file)
@@ -86,7 +86,8 @@ union { \
  */
 #define INIT_KFIFO(name) \
        name = __kfifo_initializer(sizeof(name##kfifo_buffer) - \
-                               sizeof(struct kfifo), name##kfifo_buffer)
+                               sizeof(struct kfifo), \
+                               name##kfifo_buffer + sizeof(struct kfifo))
 
 /**
  * DEFINE_KFIFO - macro to define and initialize a kfifo