* [PATCH] ext4: fix memory leakage in mext_check_coverage
@ 2013-03-18 13:35 Dmitry Monakhov
2013-03-18 15:40 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Monakhov @ 2013-03-18 13:35 UTC (permalink / raw)
To: linux-ext4; +Cc: Dmitry Monakhov
Regression was introduced by following commit 8c854473
TESTCASE (git://oss.sgi.com/xfs/cmds/xfstests.git):
#while true;do ./check 301 || break ;done
Also fix potential memory leakage in get_ext_path() once
ext4_ext_find_extent() have failed.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ext4/move_extent.c | 35 +++++++++++++++++++----------------
1 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index c1f15b2..bbae4ed 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -32,16 +32,18 @@
*/
static inline int
get_ext_path(struct inode *inode, ext4_lblk_t lblock,
- struct ext4_ext_path **path)
+ struct ext4_ext_path **orig_path)
{
int ret = 0;
+ struct ext4_ext_path *path;
- *path = ext4_ext_find_extent(inode, lblock, *path);
- if (IS_ERR(*path)) {
- ret = PTR_ERR(*path);
- *path = NULL;
- } else if ((*path)[ext_depth(inode)].p_ext == NULL)
+ path = ext4_ext_find_extent(inode, lblock, *orig_path);
+ if (IS_ERR(path))
+ ret = PTR_ERR(path);
+ else if (path[ext_depth(inode)].p_ext == NULL)
ret = -ENODATA;
+ else
+ *orig_path = path;
return ret;
}
@@ -611,24 +613,25 @@ mext_check_coverage(struct inode *inode, ext4_lblk_t from, ext4_lblk_t count,
{
struct ext4_ext_path *path = NULL;
struct ext4_extent *ext;
+ int ret = 0;
ext4_lblk_t last = from + count;
while (from < last) {
*err = get_ext_path(inode, from, &path);
if (*err)
- return 0;
+ goto out;
ext = path[ext_depth(inode)].p_ext;
- if (!ext) {
- ext4_ext_drop_refs(path);
- return 0;
- }
- if (uninit != ext4_ext_is_uninitialized(ext)) {
- ext4_ext_drop_refs(path);
- return 0;
- }
+ if (uninit != ext4_ext_is_uninitialized(ext))
+ goto out;
from += ext4_ext_get_actual_len(ext);
ext4_ext_drop_refs(path);
}
- return 1;
+ ret = 1;
+out:
+ if (path) {
+ ext4_ext_drop_refs(path);
+ kfree(path);
+ }
+ return ret;
}
/**
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext4: fix memory leakage in mext_check_coverage
2013-03-18 13:35 [PATCH] ext4: fix memory leakage in mext_check_coverage Dmitry Monakhov
@ 2013-03-18 15:40 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2013-03-18 15:40 UTC (permalink / raw)
To: Dmitry Monakhov; +Cc: linux-ext4
On Mon, Mar 18, 2013 at 05:35:29PM +0400, Dmitry Monakhov wrote:
> Regression was introduced by following commit 8c854473
> TESTCASE (git://oss.sgi.com/xfs/cmds/xfstests.git):
> #while true;do ./check 301 || break ;done
>
> Also fix potential memory leakage in get_ext_path() once
> ext4_ext_find_extent() have failed.
>
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Thanks, applied. Good catch!!
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-18 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-18 13:35 [PATCH] ext4: fix memory leakage in mext_check_coverage Dmitry Monakhov
2013-03-18 15:40 ` Theodore Ts'o
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).