udf: fix memory leak while allocating blocks during write
authorNamjae Jeon <namjae.jeon@samsung.com>
Tue, 9 Oct 2012 15:08:56 +0000 (00:08 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 16:43:58 +0000 (08:43 -0800)
commit 2fb7d99d0de3fd8ae869f35ab682581d8455887a upstream.

Need to brelse the buffer_head stored in cur_epos and next_epos.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/udf/inode.c

index 262050f2eb6c4ec5ff33f8b3c0d9038aac2fbbde..31946c51ed32819ab51867f56b7d4353250e155b 100644 (file)
@@ -738,6 +738,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
                                goal, err);
                if (!newblocknum) {
                        brelse(prev_epos.bh);
+                       brelse(cur_epos.bh);
+                       brelse(next_epos.bh);
                        *err = -ENOSPC;
                        return NULL;
                }
@@ -768,6 +770,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
        udf_update_extents(inode, laarr, startnum, endnum, &prev_epos);
 
        brelse(prev_epos.bh);
+       brelse(cur_epos.bh);
+       brelse(next_epos.bh);
 
        newblock = udf_get_pblock(inode->i_sb, newblocknum,
                                iinfo->i_location.partitionReferenceNum, 0);