Skip to contentSkip to conversation

udf: Fix error handling in udf_new_inode()

PATCH New Jan Kara 1 participant 1 message Dec 14, 2021

Subsystems (2)
lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 udf: Fix error handling in udf_new_inode()

When memory allocation of iinfo or block allocation fails, already allocated struct udf_inode_info gets freed with iput() and udf_evict_inode() may look at inode fields which are not properly initialized. Fix it by marking inode bad before dropping reference to it in udf_new_inode().

---
 fs/udf/ialloc.c | 2 ++
 1 file changed, 2 insertions(+)

I plan to queue this fix into my tree.

Honza

fs/udf/ialloc.c +2 -0
index 2ecf0e87660e..b5d611cee749 100644
@@ -77,6 +77,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
 					GFP_KERNEL);
 	}
 	if (!iinfo->i_data) {
+		make_bad_inode(inode);
 		iput(inode);
 		return ERR_PTR(-ENOMEM);
 	}
@@ -86,6 +87,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
 			      dinfo->i_location.partitionReferenceNum,
 			      start, &err);
 	if (err) {
+		make_bad_inode(inode);
 		iput(inode);
 		return ERR_PTR(err);
 	}
Signature · 1 line
2.26.2