always call inode_change_ok early in ->setattr
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / adfs / inode.c
index 6f850b06ab625e7e106a6c149f7449c223407665..b3dec193036bd95f25841eec930b845e77eefdf4 100644 (file)
@@ -50,10 +50,19 @@ static int adfs_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned flags,
                        struct page **pagep, void **fsdata)
 {
+       int ret;
+
        *pagep = NULL;
-       return cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+       ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
                                adfs_get_block,
                                &ADFS_I(mapping->host)->mmu_private);
+       if (unlikely(ret)) {
+               loff_t isize = mapping->host->i_size;
+               if (pos + len > isize)
+                       vmtruncate(mapping->host, isize);
+       }
+
+       return ret;
 }
 
 static sector_t _adfs_bmap(struct address_space *mapping, sector_t block)