Skip to content

Commit c9c6415

Browse files
cyrillosLinus Torvalds
authored and
Linus Torvalds
committed
UDF: check for allocated memory for data of new inodes
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>
1 parent d621414 commit c9c6415

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/udf/ialloc.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void udf_free_inode(struct inode * inode)
5050
else
5151
UDF_SB_LVIDIU(sb)->numFiles =
5252
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
53-
53+
5454
mark_buffer_dirty(sbi->s_lvidbh);
5555
}
5656
mutex_unlock(&sbi->s_alloc_mutex);
@@ -136,6 +136,13 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
136136
UDF_I_EFE(inode) = 0;
137137
UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
138138
}
139+
if (!UDF_I_DATA(inode))
140+
{
141+
iput(inode);
142+
*err = -ENOMEM;
143+
mutex_unlock(&sbi->s_alloc_mutex);
144+
return NULL;
145+
}
139146
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
140147
UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB;
141148
else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))

0 commit comments

Comments
 (0)