[PATCH] fix INIT_KFIFO in include/linux/kfifo.h - part 2

From: David Härdeman
Date: Tue Mar 23 2010 - 18:26:25 EST


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.

This patch was the least invasive fix I could come up with...

Signed-off-by: David Härdeman <david@xxxxxxxxxxx>
CC: stable@xxxxxxxxxx
CC: stefani@xxxxxxxxxxx
---
include/linux/kfifo.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index ece0b1c..e117b1a 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -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
--
1.7.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/