check ATTR_SIZE contraints in inode_change_ok
[firefly-linux-kernel-4.4.55.git] / fs / fat / file.c
index b2eedcee7516bfe4bc4df30ca2d2ab9d2b7a9e98..7257752b6d5d3f0c8c133597135cb2f92821f784 100644 (file)
@@ -364,18 +364,6 @@ static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode)
        return 0;
 }
 
-int fat_setsize(struct inode *inode, loff_t offset)
-{
-       int error;
-
-       error = simple_setsize(inode, offset);
-       if (error)
-               return error;
-       fat_truncate_blocks(inode, offset);
-
-       return error;
-}
-
 #define TIMES_SET_FLAGS        (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
 /* valid file mode bits */
 #define FAT_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXUGO)
@@ -441,9 +429,8 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
        }
 
        if (attr->ia_valid & ATTR_SIZE) {
-               error = fat_setsize(inode, attr->ia_size);
-               if (error)
-                       goto out;
+               truncate_setsize(inode, attr->ia_size);
+               fat_truncate_blocks(inode, attr->ia_size);
        }
 
        setattr_copy(inode, attr);