diff --git a/sys/dev/netmap/netmap_pipe.c b/sys/dev/netmap/netmap_pipe.c index 3fe29bb2ff9c..67e840248c88 100644 --- a/sys/dev/netmap/netmap_pipe.c +++ b/sys/dev/netmap/netmap_pipe.c @@ -616,7 +616,7 @@ netmap_get_pipe_na(struct nmreq *nmr, struct netmap_adapter **na, int create) sna = malloc(sizeof(*mna), M_DEVBUF, M_NOWAIT | M_ZERO); if (sna == NULL) { error = ENOMEM; - goto free_mna; + goto unregister_mna; } /* most fields are the same, copy from master and then fix */ *sna = *mna; @@ -666,6 +666,8 @@ netmap_get_pipe_na(struct nmreq *nmr, struct netmap_adapter **na, int create) free_sna: free(sna, M_DEVBUF); +unregister_mna: + netmap_pipe_remove(pna, mna); free_mna: free(mna, M_DEVBUF); put_out: