Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
[cascardo/linux.git] / fs / nilfs2 / dat.c
index fa0f803..0d5fada 100644 (file)
@@ -484,6 +484,18 @@ int nilfs_dat_read(struct super_block *sb, size_t entry_size,
        struct nilfs_dat_info *di;
        int err;
 
+       if (entry_size > sb->s_blocksize) {
+               printk(KERN_ERR
+                      "NILFS: too large DAT entry size: %zu bytes.\n",
+                      entry_size);
+               return -EINVAL;
+       } else if (entry_size < NILFS_MIN_DAT_ENTRY_SIZE) {
+               printk(KERN_ERR
+                      "NILFS: too small DAT entry size: %zu bytes.\n",
+                      entry_size);
+               return -EINVAL;
+       }
+
        dat = nilfs_iget_locked(sb, NULL, NILFS_DAT_INO);
        if (unlikely(!dat))
                return -ENOMEM;