diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2021-09-03 08:27:38 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2021-09-03 08:27:38 +0100 |
| commit | 8880cc4362fde4ecdac0b2092318893118206fcf (patch) | |
| tree | a81a9551af9a95a4d679cdfda561c089a4542b79 /hw/9pfs/9p.c | |
| parent | 8664d30a30fd676b56b4c29dbcbdd5c5538acfc1 (diff) | |
| parent | f83df00900816476cca41bb536e4d532b297d76e (diff) | |
| download | focaccia-qemu-8880cc4362fde4ecdac0b2092318893118206fcf.tar.gz focaccia-qemu-8880cc4362fde4ecdac0b2092318893118206fcf.zip | |
Merge remote-tracking branch 'remotes/cschoenebeck/tags/pull-9p-20210902' into staging
9pfs: misc patches * Fix an occasional crash when handling 'Twalk' requests. * Two code cleanup patches. # gpg: Signature made Thu 02 Sep 2021 12:42:32 BST # gpg: using RSA key 96D8D110CF7AF8084F88590134C2B58765A47395 # gpg: issuer "qemu_oss@crudebyte.com" # gpg: Good signature from "Christian Schoenebeck <qemu_oss@crudebyte.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: ECAB 1A45 4014 1413 BA38 4926 30DB 47C3 A012 D5F4 # Subkey fingerprint: 96D8 D110 CF7A F808 4F88 5901 34C2 B587 65A4 7395 * remotes/cschoenebeck/tags/pull-9p-20210902: 9pfs: fix crash in v9fs_walk() hw/9pfs: use g_autofree in v9fs_walk() where possible hw/9pfs: avoid 'path' copy in v9fs_walk() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/9pfs/9p.c')
| -rw-r--r-- | hw/9pfs/9p.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 2815257f42..c857b31321 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1703,11 +1703,12 @@ static bool same_stat_id(const struct stat *a, const struct stat *b) static void coroutine_fn v9fs_walk(void *opaque) { int name_idx; - V9fsQID *qids = NULL; + g_autofree V9fsQID *qids = NULL; int i, err = 0; V9fsPath dpath, path, *pathes = NULL; uint16_t nwnames; - struct stat stbuf, fidst, *stbufs = NULL; + struct stat stbuf, fidst; + g_autofree struct stat *stbufs = NULL; size_t offset = 7; int32_t fid, newfid; V9fsString *wnames = NULL; @@ -1787,7 +1788,8 @@ static void coroutine_fn v9fs_walk(void *opaque) strcmp("..", wnames[name_idx].data)) { err = s->ops->name_to_path(&s->ctx, &dpath, - wnames[name_idx].data, &path); + wnames[name_idx].data, + &pathes[name_idx]); if (err < 0) { err = -errno; break; @@ -1796,14 +1798,13 @@ static void coroutine_fn v9fs_walk(void *opaque) err = -EINTR; break; } - err = s->ops->lstat(&s->ctx, &path, &stbuf); + err = s->ops->lstat(&s->ctx, &pathes[name_idx], &stbuf); if (err < 0) { err = -errno; break; } stbufs[name_idx] = stbuf; - v9fs_path_copy(&dpath, &path); - v9fs_path_copy(&pathes[name_idx], &path); + v9fs_path_copy(&dpath, &pathes[name_idx]); } } }); @@ -1872,8 +1873,6 @@ out_nofid: v9fs_path_free(&pathes[name_idx]); } g_free(wnames); - g_free(qids); - g_free(stbufs); g_free(pathes); } } |