kfifo: fix kfifo_out_locked race bug
authorStefani Seibold <[email protected]>
Sat, 16 Jan 2010 01:01:02 +0000 (17:01 -0800)
committerLinus Torvalds <[email protected]>
Sat, 16 Jan 2010 20:15:37 +0000 (12:15 -0800)
Fix a wrong optimization in include/linux/kfifo.h which could cause a race
in kfifo_out_locked.

Signed-off-by: Stefani Seibold <[email protected]>
Reported-by: Johan Hovold <[email protected]>
Cc: Pete Zaitcev <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/kfifo.h

index 7c6b32a1421c000b33f1fa924f3f7ec43b32c551..c4ac88b3c30227f2473e026ec8fbe03a6213ee63 100644 (file)
@@ -228,13 +228,6 @@ static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo,
 
        ret = kfifo_out(fifo, to, n);
 
-       /*
-        * optimization: if the FIFO is empty, set the indices to 0
-        * so we don't wrap the next time
-        */
-       if (kfifo_is_empty(fifo))
-               kfifo_reset(fifo);
-
        spin_unlock_irqrestore(lock, flags);
 
        return ret;