Commit 225add619624b4877941470f31d297e0151b21be
Committed by
Linus Torvalds
1 parent
ce2c6b5384
Exists in
master
and in
7 other branches
[PATCH] udf: initialize parts of inode earlier in create
I saw an oops down this path when trying to create a new file on a UDF filesystem which was internally marked as readonly, but mounted rw: udf_create udf_new_inode new_inode alloc_inode udf_alloc_inode udf_new_block returns EIO due to readonlyness iput (on error) udf_put_inode udf_discard_prealloc udf_next_aext udf_current_aext udf_get_fileshortad OOPS the udf_discard_prealloc() path was examining uninitialized fields of the udf inode. udf_discard_prealloc() already has this code to short-circuit the discard path if no extents are preallocated: if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB || inode->i_size == UDF_I_LENEXTENTS(inode)) { return; } so if we initialize UDF_I_LENEXTENTS(inode) = 0 earlier in udf_new_inode, we won't try to free the (not) preallocated blocks, since this will match the i_size = 0 set when the inode was initialized. Signed-off-by: Eric Sandeen <sandeen@sandeen.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 6 additions and 5 deletions Side-by-side Diff
fs/udf/ialloc.c
... | ... | @@ -75,6 +75,12 @@ |
75 | 75 | } |
76 | 76 | *err = -ENOSPC; |
77 | 77 | |
78 | + UDF_I_UNIQUE(inode) = 0; | |
79 | + UDF_I_LENEXTENTS(inode) = 0; | |
80 | + UDF_I_NEXT_ALLOC_BLOCK(inode) = 0; | |
81 | + UDF_I_NEXT_ALLOC_GOAL(inode) = 0; | |
82 | + UDF_I_STRAT4096(inode) = 0; | |
83 | + | |
78 | 84 | block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum, |
79 | 85 | start, err); |
80 | 86 | if (*err) |
... | ... | @@ -84,11 +90,6 @@ |
84 | 90 | } |
85 | 91 | |
86 | 92 | mutex_lock(&sbi->s_alloc_mutex); |
87 | - UDF_I_UNIQUE(inode) = 0; | |
88 | - UDF_I_LENEXTENTS(inode) = 0; | |
89 | - UDF_I_NEXT_ALLOC_BLOCK(inode) = 0; | |
90 | - UDF_I_NEXT_ALLOC_GOAL(inode) = 0; | |
91 | - UDF_I_STRAT4096(inode) = 0; | |
92 | 93 | if (UDF_SB_LVIDBH(sb)) |
93 | 94 | { |
94 | 95 | struct logicalVolHeaderDesc *lvhd; |