From: "Huang\, Ying" <ying.huang@intel.com>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
ying.huang@intel.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: kvfree the swap cluster info if the swap file is unsatisfactory
Date: Mon, 04 Sep 2017 08:58:12 +0800 [thread overview]
Message-ID: <87o9qrqnyz.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1709010123020.102682@chino.kir.corp.google.com> (David Rientjes's message of "Fri, 1 Sep 2017 01:33:53 -0700")
David Rientjes <rientjes@google.com> writes:
> On Thu, 31 Aug 2017, Darrick J. Wong wrote:
>
>> 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.
>>
>
> Hopefully this can make it into 4.13.
>
> Fixes: 54f180d3c181 ("mm, swap: use kvzalloc to allocate some swap data structures")
> Cc: stable@vger.kernel.org [4.12]
>
>> Found by running generic/357 from xfstests.
>>
>> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
>
> Acked-by: David Rientjes <rientjes@google.com>
>
> But I think there's also a memory leak and we need this on top of your
> fix:
>
>
> mm, swapfile: fix swapon frontswap_map memory leak on error
>
> Free frontswap_map if an error is encountered before enable_swap_info().
>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
> mm/swapfile.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -3053,6 +3053,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
> spin_unlock(&swap_lock);
> vfree(swap_map);
> kvfree(cluster_info);
> + kvfree(frontswap_map);
> if (swap_file) {
> if (inode && S_ISREG(inode->i_mode)) {
> inode_unlock(inode);
Yes. There is a memory leak.
Reviewed-by: "Huang, Ying" <ying.huang@intel.com>
Best Regards,
Huang, Ying
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2017-09-04 0:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-31 23:35 [PATCH] mm: kvfree the swap cluster info if the swap file is unsatisfactory Darrick J. Wong
2017-08-31 23:41 ` taskboxtester
2017-09-01 1:33 ` Huang, Ying
2017-09-01 8:33 ` David Rientjes
2017-09-04 0:58 ` Huang, Ying [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o9qrqnyz.fsf@yhuang-dev.intel.com \
--to=ying.huang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=darrick.wong@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).