Skip to content

Commit

Permalink
net/9p/protocol.c: Fix a memory leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pedro Scarapicchia Junior authored and Eric Van Hensbergen committed May 12, 2011
1 parent ca1376d commit 1b0bcbc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/9p/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1b0bcbc

Please sign in to comment.