mm: kvfree the swap cluster info if the swap file is unsatisfactory
authorDarrick J. Wong <[email protected]>
Fri, 8 Sep 2017 23:13:25 +0000 (16:13 -0700)
committerLinus Torvalds <[email protected]>
Sat, 9 Sep 2017 01:26:47 +0000 (18:26 -0700)
If initializing a small swap file fails because the swap file has a
problem (holes, etc.) then we need to free the cluster info as part of
cleanup.  Unfortunately a previous patch changed the code to use kvzalloc
but did not change all the vfree calls to use kvfree.

Found by running generic/357 from xfstests.

Link: http://lkml.kernel.org/r/20170831233515.GR3775@magnolia
Fixes: 54f180d3c181 ("mm, swap: use kvzalloc to allocate some swap data structures")
Signed-off-by: Darrick J. Wong <[email protected]>
Reviewed-by: "Huang, Ying" <[email protected]>
Acked-by: David Rientjes <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: <[email protected]> [4.12+]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/swapfile.c

index d483278ee35b1fe9f728ec93c867dcd7621fd4af..12251d386dc76b3ad8db17014086538f80ccf686 100644 (file)
@@ -3290,7 +3290,7 @@ bad_swap:
        p->flags = 0;
        spin_unlock(&swap_lock);
        vfree(swap_map);
-       vfree(cluster_info);
+       kvfree(cluster_info);
        if (swap_file) {
                if (inode && S_ISREG(inode->i_mode)) {
                        inode_unlock(inode);