mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
Allocate all memory (including within node constructors) with M_NOWAIT
instead of M_WAITOK, to allow for maximum flexibility.
This commit is contained in:
parent
840f71272d
commit
65b9a0da90
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=66182
@ -108,7 +108,7 @@ ng_UI_constructor(node_p *nodep)
|
||||
int error;
|
||||
|
||||
/* Allocate private structure */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
|
@ -184,7 +184,7 @@ nga_constructor(node_p *nodep)
|
||||
|
||||
if ((error = ng_make_node_common(&typestruct, nodep)))
|
||||
return (error);
|
||||
MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_NOWAIT);
|
||||
if (sc == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(sc, sizeof(*sc));
|
||||
@ -193,11 +193,11 @@ nga_constructor(node_p *nodep)
|
||||
sc->cfg.amru = NG_ASYNC_DEFAULT_MRU;
|
||||
sc->cfg.smru = NG_ASYNC_DEFAULT_MRU;
|
||||
MALLOC(sc->abuf, u_char *,
|
||||
ASYNC_BUF_SIZE(sc->cfg.smru), M_NETGRAPH, M_WAITOK);
|
||||
ASYNC_BUF_SIZE(sc->cfg.smru), M_NETGRAPH, M_NOWAIT);
|
||||
if (sc->abuf == NULL)
|
||||
goto fail;
|
||||
MALLOC(sc->sbuf, u_char *,
|
||||
SYNC_BUF_SIZE(sc->cfg.amru), M_NETGRAPH, M_WAITOK);
|
||||
SYNC_BUF_SIZE(sc->cfg.amru), M_NETGRAPH, M_NOWAIT);
|
||||
if (sc->sbuf == NULL) {
|
||||
FREE(sc->abuf, M_NETGRAPH);
|
||||
fail:
|
||||
|
@ -237,7 +237,7 @@ ng_bpf_newhook(node_p node, hook_p hook, const char *name)
|
||||
int error;
|
||||
|
||||
/* Create hook private structure */
|
||||
MALLOC(hip, hinfo_p, sizeof(*hip), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(hip, hinfo_p, sizeof(*hip), M_NETGRAPH, M_NOWAIT);
|
||||
if (hip == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(hip, sizeof(*hip));
|
||||
@ -489,7 +489,7 @@ ng_bpf_setprog(hook_p hook, const struct ng_bpf_hookprog *hp0)
|
||||
|
||||
/* Make a copy of the program */
|
||||
size = NG_BPF_HOOKPROG_SIZE(hp0->bpf_prog_len);
|
||||
MALLOC(hp, struct ng_bpf_hookprog *, size, M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(hp, struct ng_bpf_hookprog *, size, M_NETGRAPH, M_NOWAIT);
|
||||
if (hp == NULL)
|
||||
return (ENOMEM);
|
||||
bcopy(hp0, hp, size);
|
||||
|
@ -196,7 +196,7 @@ cisco_constructor(node_p *nodep)
|
||||
sc_p sc;
|
||||
int error = 0;
|
||||
|
||||
MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_NOWAIT);
|
||||
if (sc == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(sc, sizeof(struct cisco_priv));
|
||||
|
@ -282,7 +282,7 @@ ng_iface_get_unit(int *unit)
|
||||
|
||||
newlen = (2 * ng_iface_units_len) + 4;
|
||||
MALLOC(newarray, int *, newlen * sizeof(*ng_iface_units),
|
||||
M_NETGRAPH, M_WAITOK);
|
||||
M_NETGRAPH, M_NOWAIT);
|
||||
if (newarray == NULL)
|
||||
return (ENOMEM);
|
||||
bcopy(ng_iface_units, newarray,
|
||||
@ -531,11 +531,11 @@ ng_iface_constructor(node_p *nodep)
|
||||
int error = 0;
|
||||
|
||||
/* Allocate node and interface private structures */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
MALLOC(ifp, struct ifnet *, sizeof(*ifp), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(ifp, struct ifnet *, sizeof(*ifp), M_NETGRAPH, M_NOWAIT);
|
||||
if (ifp == NULL) {
|
||||
FREE(priv, M_NETGRAPH);
|
||||
return (ENOMEM);
|
||||
|
@ -492,7 +492,7 @@ ng_ksocket_constructor(node_p *nodep)
|
||||
int error;
|
||||
|
||||
/* Allocate private structure */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
|
@ -190,7 +190,7 @@ nglmi_constructor(node_p *nodep)
|
||||
sc_p sc;
|
||||
int error = 0;
|
||||
|
||||
MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_NOWAIT);
|
||||
if (sc == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(sc, sizeof(*sc));
|
||||
|
@ -179,7 +179,7 @@ ng_mppc_constructor(node_p *nodep)
|
||||
int error;
|
||||
|
||||
/* Allocate private structure */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
|
@ -357,7 +357,7 @@ ng_ppp_constructor(node_p *nodep)
|
||||
int i, error;
|
||||
|
||||
/* Allocate private structure */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
|
@ -472,7 +472,7 @@ ng_pppoe_constructor(node_p *nodep)
|
||||
|
||||
AAA
|
||||
/* Initialize private descriptor */
|
||||
MALLOC(privdata, priv_p, sizeof(*privdata), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(privdata, priv_p, sizeof(*privdata), M_NETGRAPH, M_NOWAIT);
|
||||
if (privdata == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(privdata, sizeof(*privdata));
|
||||
@ -516,7 +516,7 @@ AAA
|
||||
* The infrastructure has already checked that it's unique,
|
||||
* so just allocate it and hook it in.
|
||||
*/
|
||||
MALLOC(sp, sessp, sizeof(*sp), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(sp, sessp, sizeof(*sp), M_NETGRAPH, M_NOWAIT);
|
||||
if (sp == NULL) {
|
||||
return (ENOMEM);
|
||||
}
|
||||
@ -591,7 +591,7 @@ AAA
|
||||
/*
|
||||
* set up prototype header
|
||||
*/
|
||||
MALLOC(neg, negp, sizeof(*neg), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(neg, negp, sizeof(*neg), M_NETGRAPH, M_NOWAIT);
|
||||
|
||||
if (neg == NULL) {
|
||||
printf("pppoe: Session out of memory\n");
|
||||
|
@ -280,7 +280,7 @@ ng_pptpgre_constructor(node_p *nodep)
|
||||
int error;
|
||||
|
||||
/* Allocate private structure */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
|
@ -126,7 +126,7 @@ ng_rfc1490_constructor(node_p *nodep)
|
||||
int error;
|
||||
|
||||
/* Allocate private structure */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
|
@ -152,7 +152,7 @@ ng_xxx_constructor(node_p *nodep)
|
||||
int i, error;
|
||||
|
||||
/* Initialize private descriptor */
|
||||
MALLOC(privdata, xxx_p, sizeof(*privdata), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(privdata, xxx_p, sizeof(*privdata), M_NETGRAPH, M_NOWAIT);
|
||||
if (privdata == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(privdata, sizeof(struct XXX));
|
||||
|
@ -153,7 +153,7 @@ ngt_constructor(node_p *nodep)
|
||||
sc_p privdata;
|
||||
int error = 0;
|
||||
|
||||
MALLOC(privdata, sc_p, sizeof(*privdata), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(privdata, sc_p, sizeof(*privdata), M_NETGRAPH, M_NOWAIT);
|
||||
if (privdata == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(privdata, sizeof(*privdata));
|
||||
|
@ -252,7 +252,7 @@ ng_vjc_constructor(node_p *nodep)
|
||||
int error;
|
||||
|
||||
/* Allocate private structure */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
|
Loading…
Reference in New Issue
Block a user