mm: fix nr_rotate_swap leak in swapon() error case
authorOmar Sandoval <osandov@fb.com>
Fri, 25 May 2018 21:47:17 +0000 (14:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 26 May 2018 01:12:10 +0000 (18:12 -0700)
commit7cbf319234adaa4518a28c8c523d3330e06638f0
treec25ce860d1ba8ac686456d181acca73048d3a1a5
parent62d18ecfa64137349fac9c5817784fbd48b54f48
mm: fix nr_rotate_swap leak in swapon() error case

If swapon() fails after incrementing nr_rotate_swap, we don't decrement
it and thus effectively leak it.  Make sure we decrement it if we
incremented it.

Link: http://lkml.kernel.org/r/b6fe6b879f17fa68eee6cbd876f459f6e5e33495.1526491581.git.osandov@fb.com
Fixes: 81a0298bdfab ("mm, swap: don't use VMA based swap readahead if HDD is used as swap")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Rik van Riel <riel@surriel.com>
Reviewed-by: "Huang, Ying" <ying.huang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/swapfile.c