diff options
| author | Jiri Slaby <jslaby@suse.cz> | 2010-11-06 05:06:52 -0400 |
|---|---|---|
| committer | Joel Becker <joel.becker@oracle.com> | 2010-11-18 17:10:56 -0500 |
| commit | 1cf257f511918ba5b2eabd64d9acd40f1d7866ef (patch) | |
| tree | 7ba566c24e910eb87b112e1560b294ab5779036c /fs | |
| parent | a48a982a6bd3896274dd643397c72da9258411e2 (diff) | |
ocfs2: fix memory leak
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
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs')
| -rw-r--r-- | 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 52c7557f3e25..9f26ac9be2a4 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 | |||
| 1964 | if (reg == NULL) | 1964 | if (reg == NULL) |
| 1965 | return ERR_PTR(-ENOMEM); | 1965 | return ERR_PTR(-ENOMEM); |
| 1966 | 1966 | ||
| 1967 | if (strlen(name) > O2HB_MAX_REGION_NAME_LEN) | 1967 | if (strlen(name) > O2HB_MAX_REGION_NAME_LEN) { |
| 1968 | return ERR_PTR(-ENAMETOOLONG); | 1968 | ret = -ENAMETOOLONG; |
| 1969 | goto free; | ||
| 1970 | } | ||
| 1969 | 1971 | ||
| 1970 | spin_lock(&o2hb_live_lock); | 1972 | spin_lock(&o2hb_live_lock); |
| 1971 | reg->hr_region_num = 0; | 1973 | reg->hr_region_num = 0; |
| @@ -1974,7 +1976,8 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g | |||
| 1974 | O2NM_MAX_REGIONS); | 1976 | O2NM_MAX_REGIONS); |
| 1975 | if (reg->hr_region_num >= O2NM_MAX_REGIONS) { | 1977 | if (reg->hr_region_num >= O2NM_MAX_REGIONS) { |
| 1976 | spin_unlock(&o2hb_live_lock); | 1978 | spin_unlock(&o2hb_live_lock); |
| 1977 | return ERR_PTR(-EFBIG); | 1979 | ret = -EFBIG; |
| 1980 | goto free; | ||
| 1978 | } | 1981 | } |
| 1979 | set_bit(reg->hr_region_num, o2hb_region_bitmap); | 1982 | set_bit(reg->hr_region_num, o2hb_region_bitmap); |
| 1980 | } | 1983 | } |
| @@ -1986,10 +1989,13 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g | |||
| 1986 | ret = o2hb_debug_region_init(reg, o2hb_debug_dir); | 1989 | ret = o2hb_debug_region_init(reg, o2hb_debug_dir); |
| 1987 | if (ret) { | 1990 | if (ret) { |
| 1988 | config_item_put(®->hr_item); | 1991 | config_item_put(®->hr_item); |
| 1989 | return ERR_PTR(ret); | 1992 | goto free; |
| 1990 | } | 1993 | } |
| 1991 | 1994 | ||
| 1992 | return ®->hr_item; | 1995 | return ®->hr_item; |
| 1996 | free: | ||
| 1997 | kfree(reg); | ||
| 1998 | return ERR_PTR(ret); | ||
| 1993 | } | 1999 | } |
| 1994 | 2000 | ||
| 1995 | static void o2hb_heartbeat_group_drop_item(struct config_group *group, | 2001 | static void o2hb_heartbeat_group_drop_item(struct config_group *group, |
