[PATCH] v9fs: Twalk memory leak
authorLatchesar Ionkov <lucho@ionkov.net>
Mon, 15 May 2006 16:44:18 +0000 (09:44 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 15 May 2006 18:20:56 +0000 (11:20 -0700)
v9fs leaks memory if the file server responds with Rerror to a Twalk
message.  The patch fixes the leak.

Signed-off-by: Latchesar Ionkov <lucho@ionkov.net>
Cc: Eric Van Hensbergen <ericvh@hera.kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/9p/fcall.c

index 71742ba..6f26178 100644 (file)
@@ -98,23 +98,20 @@ v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname,
 static void v9fs_t_clunk_cb(void *a, struct v9fs_fcall *tc,
        struct v9fs_fcall *rc, int err)
 {
-       int fid;
+       int fid, id;
        struct v9fs_session_info *v9ses;
 
-       if (err)
-               return;
-
+       id = 0;
        fid = tc->params.tclunk.fid;
-       kfree(tc);
-
-       if (!rc)
-               return;
-
-       v9ses = a;
-       if (rc->id == RCLUNK)
-               v9fs_put_idpool(fid, &v9ses->fidpool);
+       if (rc)
+               id = rc->id;
 
+       kfree(tc);
        kfree(rc);
+       if (id == RCLUNK) {
+               v9ses = a;
+               v9fs_put_idpool(fid, &v9ses->fidpool);
+       }
 }
 
 /**