* [PATCH] ocfs2: fix memory leak
[not found] <1289034412-24278-1-git-send-email-jslaby@suse.cz>
@ 2010-11-06 9:06 ` Jiri Slaby
2010-11-18 23:42 ` Joel Becker
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Slaby @ 2010-11-06 9:06 UTC (permalink / raw)
To: jirislaby
Cc: linux-kernel, Mark Fasheh, Joel Becker, ocfs2-devel,
Alexander Viro, linux-fsdevel
Stanse found that o2hb_heartbeat_group_make_item leaks some memory on
fail paths. Fix the paths by adding a new label and jump there.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <joel.becker@oracle.com>
Cc: ocfs2-devel@oss.oracle.com
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
---
fs/ocfs2/cluster/heartbeat.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 52c7557..9f26ac9 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1964,8 +1964,10 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
if (reg == NULL)
return ERR_PTR(-ENOMEM);
- if (strlen(name) > O2HB_MAX_REGION_NAME_LEN)
- return ERR_PTR(-ENAMETOOLONG);
+ if (strlen(name) > O2HB_MAX_REGION_NAME_LEN) {
+ ret = -ENAMETOOLONG;
+ goto free;
+ }
spin_lock(&o2hb_live_lock);
reg->hr_region_num = 0;
@@ -1974,7 +1976,8 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
O2NM_MAX_REGIONS);
if (reg->hr_region_num >= O2NM_MAX_REGIONS) {
spin_unlock(&o2hb_live_lock);
- return ERR_PTR(-EFBIG);
+ ret = -EFBIG;
+ goto free;
}
set_bit(reg->hr_region_num, o2hb_region_bitmap);
}
@@ -1986,10 +1989,13 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
ret = o2hb_debug_region_init(reg, o2hb_debug_dir);
if (ret) {
config_item_put(®->hr_item);
- return ERR_PTR(ret);
+ goto free;
}
return ®->hr_item;
+free:
+ kfree(reg);
+ return ERR_PTR(ret);
}
static void o2hb_heartbeat_group_drop_item(struct config_group *group,
--
1.7.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ocfs2: fix memory leak
2010-11-06 9:06 ` [PATCH] ocfs2: fix memory leak Jiri Slaby
@ 2010-11-18 23:42 ` Joel Becker
0 siblings, 0 replies; 2+ messages in thread
From: Joel Becker @ 2010-11-18 23:42 UTC (permalink / raw)
To: Jiri Slaby
Cc: jirislaby, Mark Fasheh, linux-kernel, Alexander Viro,
linux-fsdevel, ocfs2-devel
On Sat, Nov 06, 2010 at 10:06:52AM +0100, Jiri Slaby wrote:
> Stanse found that o2hb_heartbeat_group_make_item leaks some memory on
> fail paths. Fix the paths by adding a new label and jump there.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Mark Fasheh <mfasheh@suse.com>
> Cc: Joel Becker <joel.becker@oracle.com>
> Cc: ocfs2-devel@oss.oracle.com
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: linux-fsdevel@vger.kernel.org
This patch is now in the fixes branch of ocfs2.git.
Joel
--
"In a crisis, don't hide behind anything or anybody. They're going
to find you anyway."
- Paul "Bear" Bryant
Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-18 23:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1289034412-24278-1-git-send-email-jslaby@suse.cz>
2010-11-06 9:06 ` [PATCH] ocfs2: fix memory leak Jiri Slaby
2010-11-18 23:42 ` Joel Becker
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).