From: Karel Zak Date: Wed, 12 Dec 2012 11:40:48 +0000 (+0100) Subject: swapon: fix memmory leak [coverity scan] X-Git-Tag: v2.23-rc1~429 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=880f09c828cd5b29d65a71b9a5337568236b3207;p=thirdparty%2Futil-linux.git swapon: fix memmory leak [coverity scan] Signed-off-by: Karel Zak --- diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index 47ff508168..176be426e1 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -211,11 +211,11 @@ static int display_summary(void) static int show_table(int tt_flags, int bytes) { struct libmnt_table *st = get_swaps(); - struct libmnt_iter *itr; + struct libmnt_iter *itr = NULL; struct libmnt_fs *fs; int i, rc = 0; - struct tt *tt; + struct tt *tt = NULL; if (!st) return -1; @@ -227,7 +227,7 @@ static int show_table(int tt_flags, int bytes) tt = tt_new_table(tt_flags); if (!tt) { warn(_("failed to initialize output table")); - return -1; + goto done; } for (i = 0; i < ncolumns; i++) { @@ -243,9 +243,9 @@ static int show_table(int tt_flags, int bytes) while (mnt_table_next_fs(st, itr, &fs) == 0) add_tt_line(tt, fs, bytes); - mnt_free_iter(itr); tt_print_table(tt); done: + mnt_free_iter(itr); tt_free_table(tt); return rc; }