[PATCH 1/3] kfifo: Make kfifo_initialized work after kfifo_free

Anton Vorontsov avorontsov at ru.mvista.com
Thu Jan 28 01:09:34 EST 2010


After kfifo rework it's no longer possible to reliably know if kfifo is
usable, since after kfifo_free(), kfifo_initialized() would still return
true. The correct behaviour is needed for at least FHCI USB driver.

This patch fixes the issue by resetting the kfifo to zero values (the
same approach is used in kfifo_alloc() if allocation failed).

Signed-off-by: Anton Vorontsov <avorontsov at ru.mvista.com>
---
 kernel/kfifo.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 32c5c15..3b00bf8 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -97,6 +97,7 @@ EXPORT_SYMBOL(kfifo_alloc);
 void kfifo_free(struct kfifo *fifo)
 {
 	kfree(fifo->buffer);
+	_kfifo_init(fifo, NULL, 0);
 }
 EXPORT_SYMBOL(kfifo_free);
 
-- 
1.6.5.7



More information about the Linuxppc-dev mailing list