mm/frontswap.c: fix the condition in BUG_ON
authorLi Haifeng <omycle@gmail.com>
Wed, 10 Dec 2014 23:44:47 +0000 (15:44 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Dec 2014 01:41:08 +0000 (17:41 -0800)
The largest index of swap device is MAX_SWAPFILES-1.  So the type should
be less than MAX_SWAPFILES.

Signed-off-by: Haifeng Li <omycle@gmail.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/frontswap.c

index f2a3571c6e22573867cf6e4ba2d481a663a3d04e..8d82809eb0859a49faea0ade42251daab1419982 100644 (file)
@@ -182,7 +182,7 @@ void __frontswap_init(unsigned type, unsigned long *map)
        if (frontswap_ops)
                frontswap_ops->init(type);
        else {
-               BUG_ON(type > MAX_SWAPFILES);
+               BUG_ON(type >= MAX_SWAPFILES);
                set_bit(type, need_init);
        }
 }