fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / isofs / inode.c
index e5fbb03..ea55b6c 100644 (file)
@@ -57,12 +57,12 @@ static void isofs_put_super(struct super_block *sb)
 static void isofs_read_inode(struct inode *);
 static int isofs_statfs (struct dentry *, struct kstatfs *);
 
-static kmem_cache_t *isofs_inode_cachep;
+static struct kmem_cache *isofs_inode_cachep;
 
 static struct inode *isofs_alloc_inode(struct super_block *sb)
 {
        struct iso_inode_info *ei;
-       ei = kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL);
+       ei = kmem_cache_alloc(isofs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -73,7 +73,7 @@ static void isofs_destroy_inode(struct inode *inode)
        kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
 }
 
-static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct iso_inode_info *ei = foo;
 
@@ -96,9 +96,7 @@ static int init_inodecache(void)
 
 static void destroy_inodecache(void)
 {
-       if (kmem_cache_destroy(isofs_inode_cachep))
-               printk(KERN_INFO "iso_inode_cache: not all structures were "
-                                       "freed\n");
+       kmem_cache_destroy(isofs_inode_cachep);
 }
 
 static int isofs_remount(struct super_block *sb, int *flags, char *data)
@@ -557,11 +555,10 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
        struct iso9660_options          opt;
        struct isofs_sb_info          * sbi;
 
-       sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
+       sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
        if (!sbi)
                return -ENOMEM;
        s->s_fs_info = sbi;
-       memset(sbi, 0, sizeof(*sbi));
 
        if (!parse_options((char *)data, &opt))
                goto out_freesbi;
@@ -963,30 +960,30 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
                        goto abort;
                }
                
-               if (nextblk) {
-                       while (b_off >= (offset + sect_size)) {
-                               struct inode *ninode;
-                               
-                               offset += sect_size;
-                               if (nextblk == 0)
-                                       goto abort;
-                               ninode = isofs_iget(inode->i_sb, nextblk, nextoff);
-                               if (!ninode)
-                                       goto abort;
-                               firstext  = ISOFS_I(ninode)->i_first_extent;
-                               sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode);
-                               nextblk   = ISOFS_I(ninode)->i_next_section_block;
-                               nextoff   = ISOFS_I(ninode)->i_next_section_offset;
-                               iput(ninode);
-                               
-                               if (++section > 100) {
-                                       printk("isofs_get_blocks: More than 100 file sections ?!?, aborting...\n");
-                                       printk("isofs_get_blocks: block=%ld firstext=%u sect_size=%u "
-                                              "nextblk=%lu nextoff=%lu\n",
-                                              iblock, firstext, (unsigned) sect_size,
-                                              nextblk, nextoff);
-                                       goto abort;
-                               }
+               /* On the last section, nextblk == 0, section size is likely to
+                * exceed sect_size by a partial block, and access beyond the
+                * end of the file will reach beyond the section size, too.
+                */
+               while (nextblk && (b_off >= (offset + sect_size))) {
+                       struct inode *ninode;
+
+                       offset += sect_size;
+                       ninode = isofs_iget(inode->i_sb, nextblk, nextoff);
+                       if (!ninode)
+                               goto abort;
+                       firstext  = ISOFS_I(ninode)->i_first_extent;
+                       sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode);
+                       nextblk   = ISOFS_I(ninode)->i_next_section_block;
+                       nextoff   = ISOFS_I(ninode)->i_next_section_offset;
+                       iput(ninode);
+
+                       if (++section > 100) {
+                               printk("isofs_get_blocks: More than 100 file sections ?!?, aborting...\n");
+                               printk("isofs_get_blocks: block=%ld firstext=%u sect_size=%u "
+                                      "nextblk=%lu nextoff=%lu\n",
+                                      iblock, firstext, (unsigned) sect_size,
+                                      nextblk, nextoff);
+                               goto abort;
                        }
                }