summaryrefslogtreecommitdiffstats
path: root/sys/net/if_mpe.c
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2019-02-11 00:11:24 +0000
committerdlg <dlg@openbsd.org>2019-02-11 00:11:24 +0000
commitc14615c1f6ebc7c8aea9178f920017d623ab1183 (patch)
tree33c85c93cecf07afb7c85f9135e971b82bf3c08a /sys/net/if_mpe.c
parentwhitespace and 80 chars per line (diff)
downloadwireguard-openbsd-c14615c1f6ebc7c8aea9178f920017d623ab1183.tar.xz
wireguard-openbsd-c14615c1f6ebc7c8aea9178f920017d623ab1183.zip
add M_CANFAIL to malloc, and return ENOMEM if allocating an interface
fails.
Diffstat (limited to 'sys/net/if_mpe.c')
-rw-r--r--sys/net/if_mpe.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/net/if_mpe.c b/sys/net/if_mpe.c
index 7d185c4bded..a3862e67be3 100644
--- a/sys/net/if_mpe.c
+++ b/sys/net/if_mpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpe.c,v 1.79 2019/02/10 22:36:34 dlg Exp $ */
+/* $OpenBSD: if_mpe.c,v 1.80 2019/02/11 00:11:24 dlg Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -93,7 +93,10 @@ mpe_clone_create(struct if_clone *ifc, int unit)
struct mpe_softc *sc;
struct ifnet *ifp;
- sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_CANFAIL|M_ZERO);
+ if (sc == NULL)
+ return (ENOMEM);
+
ifp = &sc->sc_if;
snprintf(ifp->if_xname, sizeof ifp->if_xname, "mpe%d", unit);
ifp->if_flags = IFF_POINTOPOINT;