]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
9pfs: fix potential segfault during walk
authorGreg Kurz <groug@kaod.org>
Fri, 16 Sep 2016 09:44:49 +0000 (11:44 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 20 Sep 2016 15:25:06 +0000 (10:25 -0500)
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:

56f101ecce0e 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 <groug@kaod.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
[groug: updated the changelog to indicate this is regression and to provide
        the offending commit SHA1]
Signed-off-by: Greg Kurz <groug@kaod.org>
(cherry picked from commit 13fd08e631ec0c3ff5ad1bdcb6a4474c7d9a024f)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/9pfs/9p.c

index 1ac05b24deb8a461ea6470c4bc4da02a07148724..d47f5dee524869334d9e61dcac01b4e0faea2dd6 100644 (file)
@@ -1318,13 +1318,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