Date: Mon, 16 Jul 2001 02:24:39 +0900 (JST) From: Hajimu UMEMOTO <ume@mahoroba.org> To: julian@elischer.org Cc: net@FreeBSD.org, current@FreeBSD.org Subject: Re: Use of M_WAITOK in if_addmulti(). Message-ID: <20010716.022439.74683611.ume@mahoroba.org> In-Reply-To: <3B51C28F.7A56D8D8@elischer.org> References: <20010715120317.A99869@fump.kawo2.rwth-aachen.de> <20010716.001314.59549708.ume@mahoroba.org> <3B51C28F.7A56D8D8@elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> On Sun, 15 Jul 2001 09:19:27 -0700 >>>>> Julian Elischer <julian@elischer.org> said: julian> NOWAIT MAY return. julian> you have not handled the case for when it returns with a NULL allocation julian> so if it returns NULL you continue, and page-fault immediatly. Oops, thank you. How about this? Index: sys/net/if.c diff -u sys/net/if.c.orig sys/net/if.c --- sys/net/if.c.orig Mon Jul 16 01:39:34 2001 +++ sys/net/if.c Mon Jul 16 01:51:49 2001 @@ -1412,8 +1412,14 @@ llsa = 0; } - MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, M_IFMADDR, M_WAITOK); - MALLOC(dupsa, struct sockaddr *, sa->sa_len, M_IFMADDR, M_WAITOK); + MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, M_IFMADDR, M_NOWAIT); + if (iama == NULL) + return (ENOBUFS); + MALLOC(dupsa, struct sockaddr *, sa->sa_len, M_IFMADDR, M_NOWAIT); + if (dupsa == NULL) { + FREE(ifma, M_IFMADDR); + return (ENOBUFS); + } bcopy(sa, dupsa, sa->sa_len); ifma->ifma_addr = dupsa; @@ -1441,9 +1447,15 @@ ifma->ifma_refcount++; } else { MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, - M_IFMADDR, M_WAITOK); + M_IFMADDR, M_NOWAIT); + if (iama == NULL) + return (ENOBUFS); MALLOC(dupsa, struct sockaddr *, llsa->sa_len, - M_IFMADDR, M_WAITOK); + M_IFMADDR, M_NOWAIT); + if (dupsa == NULL) { + FREE(ifma, M_IFMADDR); + return (ENOBUFS); + } bcopy(llsa, dupsa, llsa->sa_len); ifma->ifma_addr = dupsa; ifma->ifma_ifp = ifp; -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan ume@mahoroba.org ume@bisd.hitachi.co.jp ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010716.022439.74683611.ume>