Commit d1807793 authored by Zoltan Menyhart's avatar Zoltan Menyhart Committed by Linus Torvalds

[PATCH] JBD: memory leak in "journal_init_dev()"

We leak a bh ref in "journal_init_dev()" in case of failure.
Signed-off-by: default avatarZoltan Menyhart <Zoltan.Menyhart@bull.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f71b2f10
...@@ -715,18 +715,8 @@ journal_t * journal_init_dev(struct block_device *bdev, ...@@ -715,18 +715,8 @@ journal_t * journal_init_dev(struct block_device *bdev,
if (!journal) if (!journal)
return NULL; 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 descriptor can store up to n blocks -bzzz */
journal->j_blocksize = blocksize;
n = journal->j_blocksize / sizeof(journal_block_tag_t); n = journal->j_blocksize / sizeof(journal_block_tag_t);
journal->j_wbufsize = n; journal->j_wbufsize = n;
journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL); journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL);
...@@ -736,6 +726,15 @@ journal_t * journal_init_dev(struct block_device *bdev, ...@@ -736,6 +726,15 @@ journal_t * journal_init_dev(struct block_device *bdev,
kfree(journal); kfree(journal);
journal = NULL; 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; return journal;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment