btrfs: Fix memory leakage in the tree-log.c
PATCH 1/1 btrfs: Fix memory leakage in the tree-log.c
In some cases, add_inode_ref() is returning without freeing the 'name' pointer.
Added bail out to explicitly call kfree when necessary.
--- fs/btrfs/tree-log.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/btrfs/tree-log.c +10 -3
@@ -1170,13 +1170,18 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,if (!dir) dir =read_one_inode (root, parent_objectid);if (!dir) -return -ENOENT ; + { + ret = -ENOENT ; + goto bail; + } } else { ret =ref_get_fields (eb, ref_ptr, &namelen, &name, &ref_index); }if (ret) -return ret; + { + goto bail; + }/* if we already have a perfect match, we're done */ if (!inode_in_dir(root, path, btrfs_ino(dir), btrfs_ino(inode),
@@ -1214,7 +1219,6 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, } ref_ptr = (unsigned long )(ref_ptr + ref_struct_size) + namelen; -kfree (name);if (log_ref_ver) {iput (dir); dir =NULL ;
@@ -1227,6 +1231,9 @@ out:btrfs_release_path (path);iput (dir);iput (inode); +bail: +if (name) +kfree (name);return ret; }
Signature · 1 line
1.8.4
Hi,
Quoted 15 lines · Geyslan G. Bem
In some cases,
add_inode_ref()is returning without freeing the 'name' pointer.Added bail out to explicitly call kfree when necessary.
Signed-off-by Geyslan G. Bem <[email protected]>--- fs/btrfs/tree-log.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)fs/btrfs/tree-log.c +0
-0
fs/btrfs/tree-log.c static noinline int add_inode_ref(struct btrfs_trans_handle *trans, · line 1176
Quoted 8 lines
fs/btrfs/tree-log.c +4
-1@@ -1170,13 +1170,18 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,if (!dir) dir =read_one_inode (root, parent_objectid);if (!dir) -return -ENOENT ; + { + ret = -ENOENT ; + goto bail; + }
No braces required here.
fs/btrfs/tree-log.c static noinline int add_inode_ref(struct btrfs_trans_handle *trans, · line 1185
Quoted 10 lines
fs/btrfs/tree-log.c +3
-1}else { ret =ref_get_fields (eb, ref_ptr, &namelen, &name, &ref_index); }if (ret) -return ret; + { + goto bail; + }
Ditto.
Quoted 29 lines
fs/btrfs/tree-log.c +3
-2/* if we already have a perfect match, we're done */ if (!inode_in_dir(root, path, btrfs_ino(dir), btrfs_ino(inode),@@ -1214,7 +1219,6 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, } ref_ptr = (unsigned long )(ref_ptr + ref_struct_size) + namelen; -kfree (name);if (log_ref_ver) {iput (dir); dir =NULL ;@@ -1227,6 +1231,9 @@ out:btrfs_release_path (path);iput (dir);iput (inode); +bail: +if (name) +kfree (name);return ret; } --1.8.4
--
Você está recebendo esta mensagem porque se inscreveu no grupo "Kernel Brasil" dos Grupos do Google.
Para cancelar a inscrição neste grupo e parar de receber seus e-mails, envie um e-mail para [email protected]. Para postar neste grupo, envie um e-mail para [email protected].
Para ver esta discussão na web, acesse https://groups.google.com/d/msgid/kernel-br/1381360387-27535-1-git-send-email-geyslan%40gmail.com.
Para obter mais opções, acesse https://groups.google.com/groups/opt_out.
Signature · 2 lines
Regards, Felipe Pena
Felipe, thank you,
Sending v2.
Geyslan Gregório Bem
hackingbits.com
2013/10/9 Felipe Pena <[email protected]>:
Quoted 78 lines
Hi,
Quoted 15 lines · Geyslan G. Bem
In some cases,
add_inode_ref()is returning without freeing the 'name' pointer.Added bail out to explicitly call kfree when necessary.
Signed-off-by Geyslan G. Bem <[email protected]>--- fs/btrfs/tree-log.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)fs/btrfs/tree-log.c +0
-0fs/btrfs/tree-log.c static noinline int add_inode_ref(struct btrfs_trans_handle *trans, · line 1176
Quoted 8 lines
fs/btrfs/tree-log.c +4
-1@@ -1170,13 +1170,18 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,if (!dir) dir =read_one_inode (root, parent_objectid);if (!dir) -return -ENOENT ; + { + ret = -ENOENT ; + goto bail; + }No braces required here.
fs/btrfs/tree-log.c static noinline int add_inode_ref(struct btrfs_trans_handle *trans, · line 1185
Quoted 10 lines
fs/btrfs/tree-log.c +3
-1}else { ret =ref_get_fields (eb, ref_ptr, &namelen, &name, &ref_index); }if (ret) -return ret; + { + goto bail; + }Ditto.
Quoted 23 lines
fs/btrfs/tree-log.c +3
-2/* if we already have a perfect match, we're done */ if (!inode_in_dir(root, path, btrfs_ino(dir), btrfs_ino(inode),@@ -1214,7 +1219,6 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, } ref_ptr = (unsigned long )(ref_ptr + ref_struct_size) + namelen; -kfree (name);if (log_ref_ver) {iput (dir); dir =NULL ;@@ -1227,6 +1231,9 @@ out:btrfs_release_path (path);iput (dir);iput (inode); +bail: +if (name) +kfree (name);return ret; } --1.8.4
Quoted 6 lines
--
Você está recebendo esta mensagem porque se inscreveu no grupo "Kernel Brasil" dos Grupos do Google.
Para cancelar a inscrição neste grupo e parar de receber seus e-mails, envie um e-mail para [email protected]. Para postar neste grupo, envie um e-mail para [email protected].
Para ver esta discussão na web, acesse https://groups.google.com/d/msgid/kernel-br/1381360387-27535-1-git-send-email-geyslan%40gmail.com.
Para obter mais opções, acesse https://groups.google.com/groups/opt_out.--
Regards,
Felipe Pena