Bug fix for sys_truncate

Malcolm Beattie (mbeattie@sable.ox.ac.uk)
Thu, 23 May 1996 15:34:07 +0100 (BST)


There are two bugs in sys_truncate() in recent Linux versions of fs/open.c.
(1) There is an iput() missing if locks_verify_area() fails.
(2) Quotas are not reduced since the inode dquot fields aren't initialised.

Here is the fix as a unidiff patch against pre2.0.3 or later (I've checked
up to pre2.0.7 and none of those touches open.c).

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Unix Systems Programmer
Oxford University Computing Services

------------------------------ cut here ------------------------------ --- open.c.ORI Thu May 23 15:08:08 1996 +++ open.c Thu May 23 15:13:03 1996 @@ -110,8 +110,13 @@ error = locks_verify_area(FLOCK_VERIFY_WRITE, inode, NULL, length < inode->i_size ? length : inode->i_size, abs(inode->i_size - length)); - if (error) + if (error) { + iput(inode); return error; + } + if (inode->i_sb && inode->i_sb->dq_op) + inode->i_sb->dq_op->initialize(inode, -1); + error = do_truncate(inode, length); put_write_access(inode); iput(inode); ------------------------------ cut here ------------------------------