diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 06f066ba3072..5048652c6cd4 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -149,6 +149,8 @@ static struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
 	uint8_t *impuse;
 	int ret;
 
+	down_write(&iinfo->i_data_sem);
+
 	if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
 		alloctype = ICBTAG_FLAG_AD_SHORT;
 	else
@@ -157,7 +159,7 @@ static struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
 	if (!inode->i_size) {
 		iinfo->i_alloc_type = alloctype;
 		mark_inode_dirty(inode);
-		return NULL;
+		goto out;
 	}
 
 	/* alloc block, and copy data to it */
@@ -165,15 +167,15 @@ static struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
 			       iinfo->i_location.partitionReferenceNum,
 			       iinfo->i_location.logicalBlockNum, err);
 	if (!(*block))
-		return NULL;
+		goto out;
 	newblock = udf_get_pblock(inode->i_sb, *block,
 				  iinfo->i_location.partitionReferenceNum,
 				0);
 	if (!newblock)
-		return NULL;
+		goto out;
 	dbh = udf_tgetblk(inode->i_sb, newblock);
 	if (!dbh)
-		return NULL;
+		goto out;
 	lock_buffer(dbh);
 	memcpy(dbh->b_data, iinfo->i_data, inode->i_size);
 	memset(dbh->b_data + inode->i_size, 0,
@@ -197,7 +199,7 @@ static struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
 	if (ret < 0) {
 		*err = ret;
 		udf_free_blocks(inode->i_sb, inode, &eloc, 0, 1);
-		return NULL;
+		goto out;
 	}
 	mark_inode_dirty(inode);
 
@@ -213,6 +215,8 @@ static struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
 			impuse = NULL;
 		udf_fiiter_write_fi(&iter, impuse);
 	}
+	up_write(&iinfo->i_data_sem);
+
 	/*
 	 * We don't expect the iteration to fail as the directory has been
 	 * already verified to be correct
@@ -221,6 +225,9 @@ static struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
 	udf_fiiter_release(&iter);
 
 	return dbh;
+out:
+	up_write(&iinfo->i_data_sem);
+	return NULL;
 }
 
 static int udf_fiiter_add_entry(struct inode *dir, struct dentry *dentry,
@@ -766,6 +773,7 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	bool has_diriter = false;
 	int retval;
 	struct kernel_lb_addr tloc;
+	struct udf_inode_info *old_iinfo = UDF_I(old_inode);
 
 	if (flags & ~RENAME_NOREPLACE)
 		return -EINVAL;
@@ -780,11 +788,13 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 		goto out_oiter;
 	}
 
+	down_read(&old_iinfo->i_data_sem);
+
 	if (S_ISDIR(old_inode->i_mode)) {
 		if (new_inode) {
 			retval = -ENOTEMPTY;
 			if (!empty_dir(new_inode))
-				goto out_oiter;
+				goto out_unlock;
 		}
 		retval = udf_fiiter_find_entry(old_inode, &dotdot_name,
 					       &diriter);
@@ -795,7 +805,7 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 			retval = -EFSCORRUPTED;
 		}
 		if (retval)
-			goto out_oiter;
+			goto out_unlock;
 		has_diriter = true;
 		tloc = lelb_to_cpu(diriter.fi.icb.extLocation);
 		if (udf_get_lb_pblock(old_inode->i_sb, &tloc, 0) !=
@@ -805,25 +815,25 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 				"directory (ino %lu) has parent entry pointing to another inode (%lu != %u)\n",
 				old_inode->i_ino, old_dir->i_ino,
 				udf_get_lb_pblock(old_inode->i_sb, &tloc, 0));
-			goto out_oiter;
+			goto out_unlock;
 		}
 	}
 
 	retval = udf_fiiter_find_entry(new_dir, &new_dentry->d_name, &niter);
 	if (retval && retval != -ENOENT)
-		goto out_oiter;
+		goto out_unlock;
 	/* Entry found but not passed by VFS? */
 	if (!retval && !new_inode) {
 		retval = -EFSCORRUPTED;
 		udf_fiiter_release(&niter);
-		goto out_oiter;
+		goto out_unlock;
 	}
 	/* Entry not found? Need to add one... */
 	if (retval) {
 		udf_fiiter_release(&niter);
 		retval = udf_fiiter_add_entry(new_dir, new_dentry, &niter);
 		if (retval)
-			goto out_oiter;
+			goto out_unlock;
 	}
 
 	/*
@@ -882,7 +892,10 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 			mark_inode_dirty(new_dir);
 		}
 	}
+	up_read(&old_iinfo->i_data_sem);
 	return 0;
+out_unlock:
+	up_read(&old_iinfo->i_data_sem);
 out_oiter:
 	if (has_diriter)
 		udf_fiiter_release(&diriter);
