if_wg: wg_clone_create: Use M_WAITOK with malloc
Signed-off-by: John Baldwin <jhb@FreeBSD.org>
This commit is contained in:
parent
8c2797b04a
commit
7196782c5d
16
src/if_wg.c
16
src/if_wg.c
|
@ -2736,17 +2736,13 @@ wg_clone_create(struct if_clone *ifc, int unit, caddr_t params)
|
|||
struct wg_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
|
||||
if ((sc = malloc(sizeof(*sc), M_WG, M_NOWAIT | M_ZERO)) == NULL)
|
||||
goto free_none;
|
||||
sc = malloc(sizeof(*sc), M_WG, M_WAITOK | M_ZERO);
|
||||
|
||||
if ((sc->sc_local = noise_local_alloc(sc)) == NULL)
|
||||
goto free_sc;
|
||||
sc->sc_local = noise_local_alloc(sc);
|
||||
|
||||
if ((sc->sc_encrypt = mallocarray(sizeof(struct grouptask), mp_ncpus, M_WG, M_NOWAIT | M_ZERO)) == NULL)
|
||||
goto free_local;
|
||||
sc->sc_encrypt = mallocarray(sizeof(struct grouptask), mp_ncpus, M_WG, M_WAITOK | M_ZERO);
|
||||
|
||||
if ((sc->sc_decrypt = mallocarray(sizeof(struct grouptask), mp_ncpus, M_WG, M_NOWAIT | M_ZERO)) == NULL)
|
||||
goto free_encrypt;
|
||||
sc->sc_decrypt = mallocarray(sizeof(struct grouptask), mp_ncpus, M_WG, M_WAITOK | M_ZERO);
|
||||
|
||||
if (!rn_inithead((void **)&sc->sc_aip4, offsetof(struct aip_addr, in) * NBBY))
|
||||
goto free_decrypt;
|
||||
|
@ -2814,13 +2810,9 @@ free_aip4:
|
|||
free(sc->sc_aip4, M_RTABLE);
|
||||
free_decrypt:
|
||||
free(sc->sc_decrypt, M_WG);
|
||||
free_encrypt:
|
||||
free(sc->sc_encrypt, M_WG);
|
||||
free_local:
|
||||
noise_local_free(sc->sc_local, NULL);
|
||||
free_sc:
|
||||
free(sc, M_WG);
|
||||
free_none:
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
|
|
|
@ -181,9 +181,7 @@ noise_local_alloc(void *arg)
|
|||
struct noise_local *l;
|
||||
size_t i;
|
||||
|
||||
l = malloc(sizeof(*l), M_NOISE, M_NOWAIT | M_ZERO);
|
||||
if (!l)
|
||||
return (NULL);
|
||||
l = malloc(sizeof(*l), M_NOISE, M_WAITOK | M_ZERO);
|
||||
|
||||
rw_init(&l->l_identity_lock, "noise_identity");
|
||||
l->l_has_identity = false;
|
||||
|
|
Loading…
Reference in New Issue