GFS2: Get a block reservation before resizing a file

This patch allocates a block reservation structure before growing
or shrinking a file. Without this structure, the grow or shink code
can reference the bad pointer.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
Bob Peterson 2013-02-01 12:03:02 -05:00 committed by Steven Whitehouse
parent 4506a519f2
commit d2b47cfb26

View File

@ -1288,6 +1288,10 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
inode_dio_wait(inode);
ret = gfs2_rs_alloc(GFS2_I(inode));
if (ret)
return ret;
oldsize = inode->i_size;
if (newsize >= oldsize)
return do_grow(inode, newsize);