git: 88024c4a520b - main - libnetmap: restore changes in 26c29e743bbdbb82762540f72d4bc449bae2e092
Vincenzo Maffione
vmaffione at FreeBSD.org
Tue Mar 30 09:53:26 UTC 2021
The branch main has been updated by vmaffione:
URL: https://cgit.FreeBSD.org/src/commit/?id=88024c4a520bf762cf4154d730ad9784ed2acd90
commit 88024c4a520bf762cf4154d730ad9784ed2acd90
Author: Vincenzo Maffione <vmaffione at FreeBSD.org>
AuthorDate: 2021-03-30 09:42:50 +0000
Commit: Vincenzo Maffione <vmaffione at FreeBSD.org>
CommitDate: 2021-03-30 09:53:14 +0000
libnetmap: restore changes in 26c29e743bbdbb82762540f72d4bc449bae2e092
Commit f8113f0a65ada9367bcbfa6e0d5d8a8451dd8ac2 accidentally
reverted some fixes introduced by 26c29e743bbdbb82762540f72d4bc449bae2e092.
This change restores them.
---
lib/libnetmap/nmreq.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/libnetmap/nmreq.c b/lib/libnetmap/nmreq.c
index 39ee53c818c5..390f791cb4dd 100644
--- a/lib/libnetmap/nmreq.c
+++ b/lib/libnetmap/nmreq.c
@@ -603,10 +603,9 @@ nmreq_options_decode(const char *opt, struct nmreq_opt_parser parsers[],
struct nmreq_option *
nmreq_find_option(struct nmreq_header *h, uint32_t t)
{
- struct nmreq_option *o;
+ struct nmreq_option *o = NULL;
- for (o = (struct nmreq_option *)h->nr_options; o != NULL;
- o = (struct nmreq_option *)o->nro_next) {
+ nmreq_foreach_option(h, o) {
if (o->nro_reqtype == t)
break;
}
@@ -633,8 +632,14 @@ nmreq_free_options(struct nmreq_header *h)
{
struct nmreq_option *o, *next;
- for (o = (struct nmreq_option *)h->nr_options; o != NULL; o = next) {
- next = (struct nmreq_option *)o->nro_next;
+ /*
+ * Note: can't use nmreq_foreach_option() here; it frees the
+ * list as it's walking and nmreq_foreach_option() isn't
+ * modification-safe.
+ */
+ for (o = (struct nmreq_option *)(uintptr_t)h->nr_options; o != NULL;
+ o = next) {
+ next = (struct nmreq_option *)(uintptr_t)o->nro_next;
free(o);
}
}
More information about the dev-commits-src-main
mailing list