[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1507769765-13478-1-git-send-email-liu.song11@zte.com.cn>
Date: Thu, 12 Oct 2017 08:56:05 +0800
From: Liu Song <liu.song11@....com.cn>
To: dwmw2@...radead.org
Cc: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
liu.song11@....com.cn, jiang.biao2@....com.cn,
zhong.weidong@....com.cn
Subject: [PATCH] jffs2: fix potential deadlock in jffs2_do_setattr
In jffs2_do_setattr, we hold two mutexes which are
A) c->alloc_sem
B) f->sem
If new_metadata is error, then we release mutexes in bad sequence
which could cause ABAB deadlock.
This patch adjusts release sequence which could avoid deadlock.
Signed-off-by: Liu Song <liu.song11@....com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@....com.cn>
---
fs/jffs2/fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 76fa814..f998126 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -140,9 +140,9 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
kfree(mdata);
if (IS_ERR(new_metadata)) {
- jffs2_complete_reservation(c);
jffs2_free_raw_inode(ri);
mutex_unlock(&f->sem);
+ jffs2_complete_reservation(c);
return PTR_ERR(new_metadata);
}
/* It worked. Update the inode */
--
2.1.0.GIT
Powered by blists - more mailing lists