[PATCH] v9fs: fix handling of malformed 9P messages
This patch attempts to do a better job of cleaning up after detecting errors
on the transport. This should also improve error reporting on broken
connections to servers.
Signed-off-by: Latchesar Ionkov <lucho@ionkov.net>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c
index 081d1c8..01e26f0 100644
--- a/fs/9p/trans_sock.c
+++ b/fs/9p/trans_sock.c
@@ -254,7 +254,12 @@
static void v9fs_sock_close(struct v9fs_transport *trans)
{
- struct v9fs_trans_sock *ts = trans ? trans->priv : NULL;
+ struct v9fs_trans_sock *ts;
+
+ if (!trans)
+ return;
+
+ ts = trans->priv;
if ((ts) && (ts->s)) {
dprintk(DEBUG_TRANS, "closing the socket %p\n", ts->s);
@@ -264,7 +269,10 @@
dprintk(DEBUG_TRANS, "socket closed\n");
}
- kfree(ts);
+ if (ts)
+ kfree(ts);
+
+ trans->priv = NULL;
}
struct v9fs_transport v9fs_trans_tcp = {