From 2711ca1c2344b7a8d38e36508f3daae261da7a02 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 21 Mar 2007 16:48:47 -0400 Subject: [PATCH] [COVERITY] Fix memory leak in libe2p (e2p_edit_feature) Coverity ID: 15: Resource Leak Signed-off-by: Brian Behlendorf Signed-off-by: "Theodore Ts'o" --- lib/e2p/ChangeLog | 4 ++++ lib/e2p/feature.c | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog index c5f08661c..0518b2a1a 100644 --- a/lib/e2p/ChangeLog +++ b/lib/e2p/ChangeLog @@ -1,3 +1,7 @@ +2007-03-21 Theodore Tso + + * feature.c (e2p_edit_feature): Fix memory leak. + 2006-11-12 Theodore Tso * feature.c: Add support for printing the huge_file, gdt_checksum, diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c index ea0c6fa01..fe7e65a85 100644 --- a/lib/e2p/feature.c +++ b/lib/e2p/feature.c @@ -165,10 +165,11 @@ static char *skip_over_word(char *cp) */ int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array) { - char *cp, *buf, *next; - int neg; + char *cp, *buf, *next; + int neg; unsigned int mask; int compat_type; + int rc = 0; buf = malloc(strlen(str)+1); if (!buf) @@ -200,15 +201,19 @@ int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array) cp++; break; } - if (e2p_string2feature(cp, &compat_type, &mask)) - return 1; - if (ok_array && !(ok_array[compat_type] & mask)) - return 1; + if (e2p_string2feature(cp, &compat_type, &mask)) { + rc = 1; + break; + } + if (ok_array && !(ok_array[compat_type] & mask)) { + rc = 1; + break; + } if (neg) compat_array[compat_type] &= ~mask; else compat_array[compat_type] |= mask; } - return 0; + free(buf); + return rc; } - -- 2.47.2