diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2022-07-18 20:06:24 +0100 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2022-08-01 01:34:44 -0500 |
commit | c6f62f81b488d00afaa86bae26c6ce9ab12c709e (patch) | |
tree | cc6c26751f0ce276a15e4e79a165689be7cbb440 /fs/cifs | |
parent | 89e42f49ef58bf5601ce452683aad1cb1088878f (diff) | |
download | linux-c6f62f81b488d00afaa86bae26c6ce9ab12c709e.tar.gz linux-c6f62f81b488d00afaa86bae26c6ce9ab12c709e.tar.bz2 linux-c6f62f81b488d00afaa86bae26c6ce9ab12c709e.zip |
cifs: Fix memory leak when using fscache
If we hit the 'index == next_cached' case, we leak a refcount on the
struct page. Fix this by using readahead_folio() which takes care of
the refcount for you.
Fixes: 0174ee9947bd ("cifs: Implement cache I/O by accessing the cache directly")
Cc: David Howells <dhowells@redhat.com>
Cc: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/file.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index e64cda7a7610..6985710e14c2 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -4459,10 +4459,10 @@ static void cifs_readahead(struct readahead_control *ractl) * TODO: Send a whole batch of pages to be read * by the cache. */ - page = readahead_page(ractl); - last_batch_size = 1 << thp_order(page); + struct folio *folio = readahead_folio(ractl); + last_batch_size = folio_nr_pages(folio); if (cifs_readpage_from_fscache(ractl->mapping->host, - page) < 0) { + &folio->page) < 0) { /* * TODO: Deal with cache read failure * here, but for the moment, delegate @@ -4470,7 +4470,7 @@ static void cifs_readahead(struct readahead_control *ractl) */ caching = false; } - unlock_page(page); + folio_unlock(folio); next_cached++; cache_nr_pages--; if (cache_nr_pages == 0) |