Skip to content

Commit

Permalink
9pfs: simplify v9fs_walk()
Browse files Browse the repository at this point in the history
There is only one comparison between nwnames and P9_MAXWELEM required.

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <E1liKiz-0006BC-Ja@lizzy.crudebyte.com>
  • Loading branch information
cschoenebeck committed Jul 5, 2021
1 parent 6f56908 commit 232a4d2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hw/9pfs/9p.c
Expand Up @@ -1739,7 +1739,11 @@ static void coroutine_fn v9fs_walk(void *opaque)

trace_v9fs_walk(pdu->tag, pdu->id, fid, newfid, nwnames);

if (nwnames && nwnames <= P9_MAXWELEM) {
if (nwnames > P9_MAXWELEM) {
err = -EINVAL;
goto out_nofid;
}
if (nwnames) {
wnames = g_new0(V9fsString, nwnames);
qids = g_new0(V9fsQID, nwnames);
for (i = 0; i < nwnames; i++) {
Expand All @@ -1753,9 +1757,6 @@ static void coroutine_fn v9fs_walk(void *opaque)
}
offset += err;
}
} else if (nwnames > P9_MAXWELEM) {
err = -EINVAL;
goto out_nofid;
}
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
Expand Down

0 comments on commit 232a4d2

Please sign in to comment.