mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
afs: Fix page leak on afs_write_begin() failure
[ Upstream commit21db2cdc66] Fix the leak of the target page in afs_write_begin() when it fails. Fixes:15b4650e55("afs: convert to new aops") Signed-off-by: David Howells <dhowells@redhat.com> cc: Nick Piggin <npiggin@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
67375bd879
commit
a88bbf94e2
@@ -76,7 +76,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
|
|||||||
*/
|
*/
|
||||||
int afs_write_begin(struct file *file, struct address_space *mapping,
|
int afs_write_begin(struct file *file, struct address_space *mapping,
|
||||||
loff_t pos, unsigned len, unsigned flags,
|
loff_t pos, unsigned len, unsigned flags,
|
||||||
struct page **pagep, void **fsdata)
|
struct page **_page, void **fsdata)
|
||||||
{
|
{
|
||||||
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
|
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
|
||||||
struct page *page;
|
struct page *page;
|
||||||
@@ -110,9 +110,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
|
|||||||
SetPageUptodate(page);
|
SetPageUptodate(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* page won't leak in error case: it eventually gets cleaned off LRU */
|
|
||||||
*pagep = page;
|
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
/* See if this page is already partially written in a way that we can
|
/* See if this page is already partially written in a way that we can
|
||||||
* merge the new write with.
|
* merge the new write with.
|
||||||
@@ -155,6 +152,7 @@ try_again:
|
|||||||
set_page_private(page, priv);
|
set_page_private(page, priv);
|
||||||
else
|
else
|
||||||
attach_page_private(page, (void *)priv);
|
attach_page_private(page, (void *)priv);
|
||||||
|
*_page = page;
|
||||||
_leave(" = 0");
|
_leave(" = 0");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -164,17 +162,18 @@ try_again:
|
|||||||
flush_conflicting_write:
|
flush_conflicting_write:
|
||||||
_debug("flush conflict");
|
_debug("flush conflict");
|
||||||
ret = write_one_page(page);
|
ret = write_one_page(page);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
_leave(" = %d", ret);
|
goto error;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = lock_page_killable(page);
|
ret = lock_page_killable(page);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
|
goto error;
|
||||||
|
goto try_again;
|
||||||
|
|
||||||
|
error:
|
||||||
|
put_page(page);
|
||||||
_leave(" = %d", ret);
|
_leave(" = %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
goto try_again;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user