]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
kfifo: Make kfifo_initialized work after kfifo_free
authorAnton Vorontsov <avorontsov@ru.mvista.com>
Wed, 27 Jan 2010 14:09:34 +0000 (17:09 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Feb 2010 23:11:06 +0000 (15:11 -0800)
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@ru.mvista.com>
Acked-by: Stefani Seibold <stefani@seibold.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/kfifo.c

index 498cabba225e9c90fa37edc1cda2120dbcd27a1f..559fb5582b602343def45aeeada25d1d1550dfa1 100644 (file)
@@ -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);