do not free NULL if pipe allocation fails

This commit is contained in:
Luigi Rizzo 2015-07-19 18:05:49 +00:00
parent 05f7605789
commit 9694aad375
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285697

View File

@ -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); sna = malloc(sizeof(*mna), M_DEVBUF, M_NOWAIT | M_ZERO);
if (sna == NULL) { if (sna == NULL) {
error = ENOMEM; error = ENOMEM;
goto free_mna; goto unregister_mna;
} }
/* most fields are the same, copy from master and then fix */ /* most fields are the same, copy from master and then fix */
*sna = *mna; *sna = *mna;
@ -666,6 +666,8 @@ netmap_get_pipe_na(struct nmreq *nmr, struct netmap_adapter **na, int create)
free_sna: free_sna:
free(sna, M_DEVBUF); free(sna, M_DEVBUF);
unregister_mna:
netmap_pipe_remove(pna, mna);
free_mna: free_mna:
free(mna, M_DEVBUF); free(mna, M_DEVBUF);
put_out: put_out: