Skip to content

Commit

Permalink
9pfs: fix potential segfault during walk
Browse files Browse the repository at this point in the history
If the call to fid_to_qid() returns an error, we will call v9fs_path_free()
on uninitialized paths.

It is a regression introduced by the following commit:

56f101e 9pfs: handle walk of ".." in the root directory

Let's fix this by initializing dpath and path before calling fid_to_qid().

Signed-off-by: Greg Kurz <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
[groug: updated the changelog to indicate this is regression and to provide
        the offending commit SHA1]
Signed-off-by: Greg Kurz <[email protected]>
  • Loading branch information
gkurz committed Sep 19, 2016
1 parent 557a4cc commit 13fd08e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hw/9pfs/9p.c
Original file line number Diff line number Diff line change
Expand Up @@ -1333,13 +1333,14 @@ static void v9fs_walk(void *opaque)
goto out_nofid;
}

v9fs_path_init(&dpath);
v9fs_path_init(&path);

err = fid_to_qid(pdu, fidp, &qid);
if (err < 0) {
goto out;
}

v9fs_path_init(&dpath);
v9fs_path_init(&path);
/*
* Both dpath and path initially poin to fidp.
* Needed to handle request with nwnames == 0
Expand Down

0 comments on commit 13fd08e

Please sign in to comment.