net/9p/protocol.c: Fix a memory leak
authorPedro Scarapicchia Junior <pedrinho.rep51@gmail.com>
Mon, 9 May 2011 14:10:49 +0000 (14:10 +0000)
committerEric Van Hensbergen <ericvh@gmail.com>
Thu, 12 May 2011 22:05:37 +0000 (17:05 -0500)
When p9pdu_readf() is called with "s" attribute, it allocates a pointer that
will store a string. In p9dirent_read(), this pointer is not being released,
leading to out of memory errors.
This patch releases this pointer after string is copyed to dirent->d_name.

Signed-off-by: Pedro Scarapicchia Junior <pedro.scarapiccha@br.flextronics.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
net/9p/protocol.c

index b58a501cf3d124a06939d266002bf48a92863ee1..a873277cb996810162ee875db9485952144541bb 100644 (file)
@@ -674,6 +674,7 @@ int p9dirent_read(char *buf, int len, struct p9_dirent *dirent,
        }
 
        strcpy(dirent->d_name, nameptr);
+       kfree(nameptr);
 
 out:
        return fake_pdu.offset;