virtio-9p: Fix a memory leak
PATCH 1/1 virtio-9p: Fix a memory leak
At v9fs_walk_complete(), the memory allocated at v9fs_walk() is not being released leading system to crash due out of memory.
This patch releases structure V9fsWalkState after v9fs_walk is complete.
--- hw/9pfs/virtio-9p.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
hw/9pfs/virtio-9p.c +2 -0
@@ -1490,6 +1490,8 @@ static void v9fs_walk_complete(V9fsState *s, V9fsWalkState *vs, int err)qemu_free (vs->wnames);qemu_free (vs->qids); } + +qemu_free (vs); }static void v9fs_walk_marshal (V9fsWalkState *vs)
Signature · 1 line
1.7.1
Quoted 9 lines · Pedro Scarapicchia Junior
At
v9fs_walk_complete(), the memory allocated atv9fs_walk()is not being released leading system to crash due out of memory.This patch releases structure V9fsWalkState after
v9fs_walkis complete.Signed-off-by Pedro Scarapicchia Junior <[email protected]>---
hw/9pfs/virtio-9p.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)
Thanks for this patch. I suggest CCing Venkateswararao Jujjuri (JV) <[email protected]>, the virtio-9p maintainer (see MAINTAINERS file), on future patches so he can pick them up quickly.
Stefan
Am 07.05.2011 10:34, schrieb Stefan Hajnoczi:
Quoted 12 lines
Quoted 9 lines · Pedro Scarapicchia Junior
At
v9fs_walk_complete(), the memory allocated atv9fs_walk()is not being released leading system to crash due out of memory.This patch releases structure V9fsWalkState after
v9fs_walkis complete.Signed-off-by Pedro Scarapicchia Junior <[email protected]>--- hw/9pfs/virtio-9p.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 5 lines
Thanks for this patch. I suggest CCing Venkateswararao Jujjuri (JV) <[email protected]>, the virtio-9p maintainer (see
MAINTAINERSfile), on future patches so he can pick them up quickly.Stefan
Releasing the memory in v9fs_walk() were it was allocated would be cleaner and easier to review. Is this not possible?
Stefan W.
Hi Stefan,
Thanks for the comment.
I believe that it is possible to release the memory at v9fs_walk. However v9fs_walk_complete() is called from two another
functions: v9fs_walk_post_newfid_lstat() and v9fs_walk_post_oldfid_lstat(). Placing qemu_free at end of v9fs_walk_complete() solve memory leak in both cases.
Venkateswararao, what's your opinion?
Best regards,
Pedro
Quoted 31 lines · Stefan Weil
Am 07.05.2011 10:34, schrieb Stefan Hajnoczi:
On Fri, May 6, 2011 at 8:05 PM, Pedro Scarapicchia Junior
Quoted 14 lines
Quoted 11 lines · <[email protected]> wrote:
At
v9fs_walk_complete(), the memory allocated atv9fs_walk()is not being released leading system to crash due out of memory.This patch releases structure V9fsWalkState after
v9fs_walkis complete.Signed-off-by: Pedro Scarapicchia Junior <
[email protected]>--- hw/9pfs/virtio-9p.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)Quoted 6 lines
Thanks for this patch. I suggest CCing Venkateswararao Jujjuri (JV) <[email protected]>, the virtio-9p maintainer (see
MAINTAINERSfile), on future patches so he can pick them up quickly.Stefan
Releasing the memory in
v9fs_walk()were it was allocated would be cleaner and easier to review. Is this not possible?Stefan W.
Quoted 9 lines · Pedro Scarapicchia Junior
Hi Stefan,
Thanks for the comment.
I believe that it is possible to release the memory at
v9fs_walk. Howeverv9fs_walk_complete()is called from two another functions:v9fs_walk_post_newfid_lstat()
andv9fs_walk_post_oldfid_lstat(). Placingqemu_freeat end
ofv9fs_walk_complete()solve memory leak in both cases.Venkateswararao, what's your opinion?
I agree with Pedro. Given the state machine model the v9fs_walk() returns from multiple places. We can take this patch for now. A new patch set is getting brewed converting this whole method with coroutines + glib thread pools. That will replace all these *post* functions with more of a readable format. Again thanks for the patch.
- JV
Quoted 44 lines
Best regards,
Pedro
On Sat, May 7, 2011 at 5:56 AM, Stefan Weil <[email protected] <mailto:[email protected]>> wrote:
Am 07.05.2011 10:34, schrieb Stefan Hajnoczi:
On Fri, May 6, 2011 at 8:05 PM, Pedro Scarapicchia Junior <[email protected] <mailto:[email protected]>> wrote:
At
v9fs_walk_complete(), the memory allocated atv9fs_walk()is not being
released leading system to crash due out of memory.This patch releases structure V9fsWalkState after
v9fs_walkis complete.Signed-off-by: Pedro Scarapicchia Junior <[email protected] <mailto:[email protected]>>
---
hw/9pfs/virtio-9p.c| 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)Thanks for this patch. I suggest CCing Venkateswararao Jujjuri (JV)
<[email protected] <mailto:[email protected]>>, the virtio-9p maintainer (seeMAINTAINERS
file), on future patches so he can pick them up quickly.Stefan
Releasing the memory in
v9fs_walk()were it was allocated would be cleaner and easier to review. Is this not possible?Stefan W.