From: Jan Kara Date: Mon, 20 Feb 2012 16:49:56 +0000 (+0100) Subject: udf: Fix deadlock in udf_release_file() X-Git-Tag: firefly_0821_release~7541^2~1466 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bc9d8a3ba0a4b0c136c78ba5e35906401d7dc5ba;p=firefly-linux-kernel-4.4.55.git udf: Fix deadlock in udf_release_file() commit a0391a3ae91d301c0e59368531a4de5f0b122bcf upstream. udf_release_file() can be called from munmap() path with mmap_sem held. Thus we cannot take i_mutex there because that ranks above mmap_sem. Luckily, i_mutex is not needed in udf_release_file() anymore since protection by i_data_sem is enough to protect from races with write and truncate. Reported-by: Al Viro Reviewed-by: Namjae Jeon Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/udf/file.c b/fs/udf/file.c index 0c0c9d33dbc7..3438b0000413 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -201,12 +201,10 @@ out: static int udf_release_file(struct inode *inode, struct file *filp) { if (filp->f_mode & FMODE_WRITE) { - mutex_lock(&inode->i_mutex); down_write(&UDF_I(inode)->i_data_sem); udf_discard_prealloc(inode); udf_truncate_tail_extent(inode); up_write(&UDF_I(inode)->i_data_sem); - mutex_unlock(&inode->i_mutex); } return 0; }