Skip to contentSkip to conversation

v9fs: fix fd_close

PATCH New Eric Van Hensbergen 1 participant 1 message Dec 29, 2005 9P file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v9fs: fix fd_close

[PATCH] v9fs: fix fd_close

If a 9pfs server crashes, v9fs_fd_close() is called. Subsequently, in cleaning up by performing a umount() on the FS that was provided by this server v9fs_fd_close() is called again, and uses the old, freed valus of trans->priv. This patch ensures that trans->priv can be freed only once, otherwise this function bails early.

---
commit db73617a4959fa8af9f72063e3bd666c70363d99
tree 3e05d73b024cdcf7462aae64e62a63849d8aa175
parent 3603bc8dc5ab33941e6378fe52ea03b7f5561109
author Eric Van Hensbergen <[email protected]> Thu, 29 Dec 2005 10:54:06 -0600 committer Eric Van Hensbergen <[email protected]> Thu, 29 Dec 2005 10:54:06 -0600

 fs/9p/trans_fd.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/9p/trans_fd.c +2 -2
index 63b58ce..b7ffb98 100644
@@ -148,12 +148,12 @@ static void v9fs_fd_close(struct v9fs_tr
 	if (!trans)
 		return;
 
-	trans->status = Disconnected;
-	ts = trans->priv;
+	ts = xchg(&trans->priv, NULL);
 
 	if (!ts)
 		return;
 
+	trans->status = Disconnected;
 	if (ts->in_file)
 		fput(ts->in_file);