]> err.no Git - linux-2.6/commitdiff
UDF: check for allocated memory for data of new inodes
authorCyrill Gorcunov <gorcunov@gmail.com>
Mon, 16 Jul 2007 06:39:43 +0000 (23:39 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 16 Jul 2007 16:05:41 +0000 (09:05 -0700)
Add checking for granted memory for inode data at the moment of its
creation.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Jan Kara <jack@ucw.cz>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/udf/ialloc.c

index 8206983f2ebf924c1bf91629206fbc518d014c69..10f3188738af3694331d8ff803586165b7a2b338 100644 (file)
@@ -50,7 +50,7 @@ void udf_free_inode(struct inode * inode)
                else
                        UDF_SB_LVIDIU(sb)->numFiles =
                                cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
-               
+
                mark_buffer_dirty(sbi->s_lvidbh);
        }
        mutex_unlock(&sbi->s_alloc_mutex);
@@ -136,6 +136,13 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
                UDF_I_EFE(inode) = 0;
                UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
        }
+       if (!UDF_I_DATA(inode))
+       {
+               iput(inode);
+               *err = -ENOMEM;
+               mutex_unlock(&sbi->s_alloc_mutex);
+               return NULL;
+       }
        if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
                UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB;
        else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))