Skip to content

Commit

Permalink
[PATCH] JBD: memory leak in "journal_init_dev()"
Browse files Browse the repository at this point in the history
We leak a bh ref in "journal_init_dev()" in case of failure.

Signed-off-by: Zoltan Menyhart <Zoltan.Menyhart@bull.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Zoltan Menyhart authored and Linus Torvalds committed Sep 29, 2006
1 parent f71b2f1 commit d180779
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions fs/jbd/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,18 +715,8 @@ journal_t * journal_init_dev(struct block_device *bdev,
if (!journal)
return NULL;

journal->j_dev = bdev;
journal->j_fs_dev = fs_dev;
journal->j_blk_offset = start;
journal->j_maxlen = len;
journal->j_blocksize = blocksize;

bh = __getblk(journal->j_dev, start, journal->j_blocksize);
J_ASSERT(bh != NULL);
journal->j_sb_buffer = bh;
journal->j_superblock = (journal_superblock_t *)bh->b_data;

/* journal descriptor can store up to n blocks -bzzz */
journal->j_blocksize = blocksize;
n = journal->j_blocksize / sizeof(journal_block_tag_t);
journal->j_wbufsize = n;
journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL);
Expand All @@ -736,6 +726,15 @@ journal_t * journal_init_dev(struct block_device *bdev,
kfree(journal);
journal = NULL;
}
journal->j_dev = bdev;
journal->j_fs_dev = fs_dev;
journal->j_blk_offset = start;
journal->j_maxlen = len;

bh = __getblk(journal->j_dev, start, journal->j_blocksize);
J_ASSERT(bh != NULL);
journal->j_sb_buffer = bh;
journal->j_superblock = (journal_superblock_t *)bh->b_data;

return journal;
}
Expand Down

0 comments on commit d180779

Please sign in to comment.