* [PATCH v2 0/2] btrfs-progs: some bugfixes
@ 2012-09-05 9:21 Zhi Yong Wu
2012-09-05 9:21 ` [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit Zhi Yong Wu
2012-09-05 9:21 ` [PATCH v2 2/2] btrfs-progs: Fix up memory leakage Zhi Yong Wu
0 siblings, 2 replies; 6+ messages in thread
From: Zhi Yong Wu @ 2012-09-05 9:21 UTC (permalink / raw)
To: linux-btrfs; +Cc: linux-kernel, linuxram, Zhi Yong Wu
Some misc bugs are found when i work on other tasks.
Now send out them for interview, thanks.
Zhi Yong Wu (2):
btrfs-progs: Close file descriptor on exit
btrfs-progs: Fix up memory leakage
cmds-filesystem.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
--
1.7.6.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit
2012-09-05 9:21 [PATCH v2 0/2] btrfs-progs: some bugfixes Zhi Yong Wu
@ 2012-09-05 9:21 ` Zhi Yong Wu
2012-09-05 9:21 ` [PATCH v2 2/2] btrfs-progs: Fix up memory leakage Zhi Yong Wu
1 sibling, 0 replies; 6+ messages in thread
From: Zhi Yong Wu @ 2012-09-05 9:21 UTC (permalink / raw)
To: linux-btrfs; +Cc: linux-kernel, linuxram, Zhi Yong Wu
Need to close fd on exit.
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
cmds-filesystem.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index b1457de..e62c4fd 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -77,18 +77,23 @@ static int cmd_df(int argc, char **argv)
if (ret) {
fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n",
path, strerror(e));
+ close(fd);
free(sargs);
return ret;
}
- if (!sargs->total_spaces)
+ if (!sargs->total_spaces) {
+ close(fd);
return 0;
+ }
count = sargs->total_spaces;
sargs = realloc(sargs, sizeof(struct btrfs_ioctl_space_args) +
(count * sizeof(struct btrfs_ioctl_space_info)));
- if (!sargs)
+ if (!sargs) {
+ close(fd);
return -ENOMEM;
+ }
sargs->space_slots = count;
sargs->total_spaces = 0;
@@ -148,6 +153,7 @@ static int cmd_df(int argc, char **argv)
printf("%s: total=%s, used=%s\n", description, total_bytes,
used_bytes);
}
+ close(fd);
free(sargs);
return 0;
--
1.7.6.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] btrfs-progs: Fix up memory leakage
2012-09-05 9:21 [PATCH v2 0/2] btrfs-progs: some bugfixes Zhi Yong Wu
2012-09-05 9:21 ` [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit Zhi Yong Wu
@ 2012-09-05 9:21 ` Zhi Yong Wu
1 sibling, 0 replies; 6+ messages in thread
From: Zhi Yong Wu @ 2012-09-05 9:21 UTC (permalink / raw)
To: linux-btrfs; +Cc: linux-kernel, linuxram, Zhi Yong Wu
Some code pathes forget to free memory on exit.
Changelog from v1:
Fix the variable is used uncorrectly. [Ram Pai]
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
cmds-filesystem.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index e62c4fd..9c43d35 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -47,7 +47,7 @@ static const char * const cmd_df_usage[] = {
static int cmd_df(int argc, char **argv)
{
- struct btrfs_ioctl_space_args *sargs;
+ struct btrfs_ioctl_space_args *sargs, *sargs_orig;
u64 count = 0, i;
int ret;
int fd;
@@ -65,7 +65,7 @@ static int cmd_df(int argc, char **argv)
return 12;
}
- sargs = malloc(sizeof(struct btrfs_ioctl_space_args));
+ sargs_orig = sargs = malloc(sizeof(struct btrfs_ioctl_space_args));
if (!sargs)
return -ENOMEM;
@@ -83,6 +83,7 @@ static int cmd_df(int argc, char **argv)
}
if (!sargs->total_spaces) {
close(fd);
+ free(sargs);
return 0;
}
@@ -92,6 +93,7 @@ static int cmd_df(int argc, char **argv)
(count * sizeof(struct btrfs_ioctl_space_info)));
if (!sargs) {
close(fd);
+ free(sargs_orig);
return -ENOMEM;
}
--
1.7.6.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [resend][PATCH v2 0/2] btrfs-progs: some bugfixes
@ 2012-09-25 2:02 zwu.kernel
2012-09-25 2:02 ` [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit zwu.kernel
0 siblings, 1 reply; 6+ messages in thread
From: zwu.kernel @ 2012-09-25 2:02 UTC (permalink / raw)
To: linux-btrfs; +Cc: linux-kernel, jbacik, dave, linuxram, Zhi Yong Wu
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Some misc bugs are found when i work on other tasks.
Now send out them for interview, thanks.
Zhi Yong Wu (2):
btrfs-progs: Close file descriptor on exit
btrfs-progs: Fix up memory leakage
cmds-filesystem.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
--
1.7.6.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit
2012-09-25 2:02 [resend][PATCH v2 0/2] btrfs-progs: some bugfixes zwu.kernel
@ 2012-09-25 2:02 ` zwu.kernel
2012-09-25 10:12 ` David Sterba
0 siblings, 1 reply; 6+ messages in thread
From: zwu.kernel @ 2012-09-25 2:02 UTC (permalink / raw)
To: linux-btrfs; +Cc: linux-kernel, jbacik, dave, linuxram, Zhi Yong Wu
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Need to close fd on exit.
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
cmds-filesystem.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index b1457de..e62c4fd 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -77,18 +77,23 @@ static int cmd_df(int argc, char **argv)
if (ret) {
fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n",
path, strerror(e));
+ close(fd);
free(sargs);
return ret;
}
- if (!sargs->total_spaces)
+ if (!sargs->total_spaces) {
+ close(fd);
return 0;
+ }
count = sargs->total_spaces;
sargs = realloc(sargs, sizeof(struct btrfs_ioctl_space_args) +
(count * sizeof(struct btrfs_ioctl_space_info)));
- if (!sargs)
+ if (!sargs) {
+ close(fd);
return -ENOMEM;
+ }
sargs->space_slots = count;
sargs->total_spaces = 0;
@@ -148,6 +153,7 @@ static int cmd_df(int argc, char **argv)
printf("%s: total=%s, used=%s\n", description, total_bytes,
used_bytes);
}
+ close(fd);
free(sargs);
return 0;
--
1.7.6.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit
2012-09-25 2:02 ` [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit zwu.kernel
@ 2012-09-25 10:12 ` David Sterba
2012-09-25 13:58 ` Zhi Yong Wu
0 siblings, 1 reply; 6+ messages in thread
From: David Sterba @ 2012-09-25 10:12 UTC (permalink / raw)
To: zwu.kernel; +Cc: linux-btrfs, linux-kernel, jbacik, dave, linuxram, Zhi Yong Wu
On Tue, Sep 25, 2012 at 10:02:15AM +0800, zwu.kernel@gmail.com wrote:
> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>
> Need to close fd on exit.
Strictly you don't need to, kernel will do that at exit() time.
david
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit
2012-09-25 10:12 ` David Sterba
@ 2012-09-25 13:58 ` Zhi Yong Wu
0 siblings, 0 replies; 6+ messages in thread
From: Zhi Yong Wu @ 2012-09-25 13:58 UTC (permalink / raw)
To: dave, zwu.kernel, linux-btrfs, linux-kernel, jbacik, linuxram,
Zhi Yong Wu
On Tue, Sep 25, 2012 at 6:12 PM, David Sterba <dave@jikos.cz> wrote:
> On Tue, Sep 25, 2012 at 10:02:15AM +0800, zwu.kernel@gmail.com wrote:
>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>
>> Need to close fd on exit.
>
> Strictly you don't need to, kernel will do that at exit() time.
I know, but it is not so nice.
>
> david
--
Regards,
Zhi Yong Wu
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-09-25 13:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 9:21 [PATCH v2 0/2] btrfs-progs: some bugfixes Zhi Yong Wu
2012-09-05 9:21 ` [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit Zhi Yong Wu
2012-09-05 9:21 ` [PATCH v2 2/2] btrfs-progs: Fix up memory leakage Zhi Yong Wu
-- strict thread matches above, loose matches on Subject: below --
2012-09-25 2:02 [resend][PATCH v2 0/2] btrfs-progs: some bugfixes zwu.kernel
2012-09-25 2:02 ` [PATCH v2 1/2] btrfs-progs: Close file descriptor on exit zwu.kernel
2012-09-25 10:12 ` David Sterba
2012-09-25 13:58 ` Zhi Yong Wu
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).