Whamcloud - gitweb
Fix memory leak in e2fsck's error paths
authorTheodore Ts'o <tytso@mit.edu>
Sun, 14 May 2006 21:16:29 +0000 (17:16 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 14 May 2006 21:16:29 +0000 (17:16 -0400)
Add missing brelse() calls to avoid memory leaks in error paths.  (Thanks
to Michael C. Thompson for pointing these out; they were originally
found using Coverity.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/ChangeLog
e2fsck/journal.c
e2fsck/recovery.c

index 2107b71..7da142e 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-14  Theodore Tso  <tytso@mit.edu>
+
+       * recovery.c (do_one_pass), journal.c (e2fsck_get_journal): Add
+               missing brelse() calls to avoid memory leaks in error
+               paths.  (Thanks to Michael C. Thompson for pointing these
+               out; they were originally found using Coverity.)
+
 2006-05-13  Theodore Tso  <tytso@mit.edu>
 
        * badblocks.c (read_bad_blocks_file): Pass the private option -X
index a5ebe14..0cb14d3 100644 (file)
@@ -344,8 +344,10 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
                        goto errout;
                }
                ll_rw_block(READ, 1, &bh);
-               if ((retval = bh->b_err) != 0)
+               if ((retval = bh->b_err) != 0) {
+                       brelse(bh);
                        goto errout;
+               }
                memcpy(&jsuper, start ? bh->b_data :  bh->b_data + 1024,
                       sizeof(jsuper));
                brelse(bh);
index d25dd98..36e5e2b 100644 (file)
@@ -526,6 +526,7 @@ static int do_one_pass(journal_t *journal,
                default:
                        jbd_debug(3, "Unrecognised magic %d, end of scan.\n",
                                  blocktype);
+                       brelse(bh);
                        goto done;
                }
        }