Skip to content

Commit

Permalink
libnetmap: import fixes from FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
jhk098 committed Mar 30, 2021
1 parent 6782c07 commit 75477cd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions libnetmap/nmreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,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;
}
Expand All @@ -631,8 +630,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);
}
}
Expand Down

0 comments on commit 75477cd

Please sign in to comment.