* [PATCH 0/3] btrfs-progs: fix problems reported by cppcheck
@ 2012-11-15 4:47 Kenji Okimoto
2012-11-15 4:47 ` [PATCH 1/3] btrfs-progs: plug a memory leak " Kenji Okimoto
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kenji Okimoto @ 2012-11-15 4:47 UTC (permalink / raw)
To: linux-btrfs; +Cc: Kenji Okimoto
I fixed some problems reported by cppcheck:
[disk-io.c:462]: (error) Memory leak: log_root
[utils.c:983]: (error) Memory leak: fullpath
Patch set based on:
git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git#master
commit 91d9eec1ff044394f2b98ee7fcb76713dd33b994
Author: Chris Mason <chris.mason@fusionio.com>
Date: Thu Oct 4 20:35:31 2012 -0400
Kenji Okimoto (3):
btrfs-progs: plug a memory leak reported by cppcheck
btrfs-progs: check malloc() result
btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by
cppcheck.
disk-io.c | 13 +++++++++++--
utils.c | 3 +++
2 files changed, 14 insertions(+), 2 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/3] btrfs-progs: plug a memory leak reported by cppcheck
2012-11-15 4:47 [PATCH 0/3] btrfs-progs: fix problems reported by cppcheck Kenji Okimoto
@ 2012-11-15 4:47 ` Kenji Okimoto
2012-11-15 4:47 ` [PATCH 2/3] btrfs-progs: check malloc() result Kenji Okimoto
2012-11-15 4:47 ` [PATCH 3/3] btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by cppcheck Kenji Okimoto
2 siblings, 0 replies; 4+ messages in thread
From: Kenji Okimoto @ 2012-11-15 4:47 UTC (permalink / raw)
To: linux-btrfs; +Cc: Kenji Okimoto
[src/btrfs/disk-io.c:462]: (error) Memory leak: log_root
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
---
disk-io.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/disk-io.c b/disk-io.c
index 0395205..32f45dc 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -458,8 +458,10 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root,
u64 blocknr = btrfs_super_log_root(disk_super);
struct btrfs_root *log_root = malloc(sizeof(struct btrfs_root));
- if (blocknr == 0)
+ if (blocknr == 0) {
+ free(log_root);
return 0;
+ }
blocksize = btrfs_level_size(tree_root,
btrfs_super_log_root_level(disk_super));
@@ -474,8 +476,12 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root,
fs_info->log_root_tree = log_root;
- if (!extent_buffer_uptodate(log_root->node))
+ if (!extent_buffer_uptodate(log_root->node)) {
+ free(log_root);
return -EIO;
+ }
+
+ free(log_root);
return 0;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/3] btrfs-progs: check malloc() result
2012-11-15 4:47 [PATCH 0/3] btrfs-progs: fix problems reported by cppcheck Kenji Okimoto
2012-11-15 4:47 ` [PATCH 1/3] btrfs-progs: plug a memory leak " Kenji Okimoto
@ 2012-11-15 4:47 ` Kenji Okimoto
2012-11-15 4:47 ` [PATCH 3/3] btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by cppcheck Kenji Okimoto
2 siblings, 0 replies; 4+ messages in thread
From: Kenji Okimoto @ 2012-11-15 4:47 UTC (permalink / raw)
To: linux-btrfs; +Cc: Kenji Okimoto
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
---
disk-io.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/disk-io.c b/disk-io.c
index 32f45dc..c4d4631 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -458,6 +458,9 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root,
u64 blocknr = btrfs_super_log_root(disk_super);
struct btrfs_root *log_root = malloc(sizeof(struct btrfs_root));
+ if (!log_root)
+ return -ENOMEM;
+
if (blocknr == 0) {
free(log_root);
return 0;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/3] btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by cppcheck.
2012-11-15 4:47 [PATCH 0/3] btrfs-progs: fix problems reported by cppcheck Kenji Okimoto
2012-11-15 4:47 ` [PATCH 1/3] btrfs-progs: plug a memory leak " Kenji Okimoto
2012-11-15 4:47 ` [PATCH 2/3] btrfs-progs: check malloc() result Kenji Okimoto
@ 2012-11-15 4:47 ` Kenji Okimoto
2 siblings, 0 replies; 4+ messages in thread
From: Kenji Okimoto @ 2012-11-15 4:47 UTC (permalink / raw)
To: linux-btrfs; +Cc: Kenji Okimoto
[utils.c:983]: (error) Memory leak: fullpath
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
---
utils.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/utils.c b/utils.c
index 205e667..3efb3af 100644
--- a/utils.c
+++ b/utils.c
@@ -980,6 +980,7 @@ again:
dirp = opendir(dirname);
if (!dirp) {
fprintf(stderr, "Unable to open %s for scanning\n", dirname);
+ free(fullpath);
return -ENOENT;
}
while(1) {
@@ -1030,6 +1031,7 @@ again:
free(pending);
pending = list_entry(pending_list.next, struct pending_dir,
list);
+ free(fullpath);
list_del(&pending->list);
closedir(dirp);
dirp = NULL;
@@ -1038,6 +1040,7 @@ again:
ret = 0;
fail:
free(pending);
+ free(fullpath);
if (dirp)
closedir(dirp);
return ret;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-15 4:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-15 4:47 [PATCH 0/3] btrfs-progs: fix problems reported by cppcheck Kenji Okimoto
2012-11-15 4:47 ` [PATCH 1/3] btrfs-progs: plug a memory leak " Kenji Okimoto
2012-11-15 4:47 ` [PATCH 2/3] btrfs-progs: check malloc() result Kenji Okimoto
2012-11-15 4:47 ` [PATCH 3/3] btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by cppcheck Kenji Okimoto
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.