From 861dac9b254ca71c5a0ca81fcbdf5271ad920c44 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Mon, 11 Feb 2019 00:11:25 +0000 Subject: add M_CANFAIL to malloc, and return ENOMEM if allocating an interface fails. --- sys/net/if_mpw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sys/net/if_mpw.c') 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 @@ -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); -- cgit v1.2.3