Patch "mm/swapfile.c: fix potential memory leak in sys_swapon" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mm/swapfile.c: fix potential memory leak in sys_swapon

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mm-swapfile.c-fix-potential-memory-leak-in-sys_swapo.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d768dda2af5b5fb16c312eaa0419df3957fd6395
Author: Miaohe Lin <linmiaohe@xxxxxxxxxx>
Date:   Tue Oct 13 16:52:30 2020 -0700

    mm/swapfile.c: fix potential memory leak in sys_swapon
    
    [ Upstream commit 822bca52ee7eb279acfba261a423ed7ac47d6f73 ]
    
    If we failed to drain inode, we would forget to free the swap address
    space allocated by init_swap_address_space() above.
    
    Fixes: dc617f29dbe5 ("vfs: don't allow writes to swap files")
    Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
    Link: https://lkml.kernel.org/r/20200930101803.53884-1-linmiaohe@xxxxxxxxxx
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/mm/swapfile.c b/mm/swapfile.c
index cf62bdb7b3045..ff83ffe7a9108 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3284,7 +3284,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 	error = inode_drain_writes(inode);
 	if (error) {
 		inode->i_flags &= ~S_SWAPFILE;
-		goto bad_swap_unlock_inode;
+		goto free_swap_address_space;
 	}
 
 	mutex_lock(&swapon_mutex);
@@ -3309,6 +3309,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 
 	error = 0;
 	goto out;
+free_swap_address_space:
+	exit_swap_address_space(p->type);
 bad_swap_unlock_inode:
 	inode_unlock(inode);
 bad_swap:



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux