summaryrefslogtreecommitdiff
path: root/sys/net/if_mpw.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-02-11 00:11:25 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-02-11 00:11:25 +0000
commit861dac9b254ca71c5a0ca81fcbdf5271ad920c44 (patch)
treefd10c61d7cc90e206e4f3b11e54de04d5288187c /sys/net/if_mpw.c
parent80e4f2a06849ebcc1bfb673e38798e4b7029c762 (diff)
add M_CANFAIL to malloc, and return ENOMEM if allocating an interface
fails.
Diffstat (limited to 'sys/net/if_mpw.c')
-rw-r--r--sys/net/if_mpw.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/net/if_mpw.c b/sys/net/if_mpw.c
index 2bc7104d04f..f58729c8530 100644
--- a/sys/net/if_mpw.c
+++ b/sys/net/if_mpw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpw.c,v 1.32 2019/02/10 22:58:05 dlg Exp $ */
+/* $OpenBSD: if_mpw.c,v 1.33 2019/02/11 00:11:24 dlg Exp $ */
/*
* Copyright (c) 2015 Rafael Zalamena <rzalamena@openbsd.org>
@@ -83,7 +83,10 @@ mpw_clone_create(struct if_clone *ifc, int unit)
struct mpw_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), "%s%d",
ifc->ifc_name, unit);