From owner-freebsd-current Sun Jul 15 10:25:20 2001 Delivered-To: freebsd-current@freebsd.org Received: from light.imasy.or.jp (light.imasy.or.jp [202.227.24.4]) by hub.freebsd.org (Postfix) with ESMTP id 2974637B403; Sun, 15 Jul 2001 10:25:11 -0700 (PDT) (envelope-from ume@mahoroba.org) Received: (from uucp@localhost) by light.imasy.or.jp (8.11.3+3.4W/8.11.3/light) with UUCP id f6FHP1216099; Mon, 16 Jul 2001 02:25:01 +0900 (JST) (envelope-from ume@mahoroba.org) Received: from peace.mahoroba.org (IDENT:sxTc4RZcYEQYf5SvLGaGaTycVj/Aeo06n0y4OZO1NAxuUEKkgHGMLia8iE2DyX/X@peace.mahoroba.org [2001:200:301:0:200:f8ff:fe05:3eae]) (authenticated as ume with CRAM-MD5) by mail.mahoroba.org (8.11.4/8.11.4/chaos) with ESMTP/inet6 id f6FHOgL23057; Mon, 16 Jul 2001 02:24:43 +0900 (JST) (envelope-from ume@mahoroba.org) Date: Mon, 16 Jul 2001 02:24:39 +0900 (JST) Message-Id: <20010716.022439.74683611.ume@mahoroba.org> To: julian@elischer.org Cc: net@FreeBSD.org, current@FreeBSD.org Subject: Re: Use of M_WAITOK in if_addmulti(). From: Hajimu UMEMOTO 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> X-Mailer: xcite1.38> Mew version 1.95b119 on Emacs 20.7 / Mule 4.0 =?iso-2022-jp?B?KBskQjJWMWMbKEIp?= X-PGP-Public-Key: http://www.imasy.org/~ume/publickey.asc X-PGP-Fingerprint: 6B 0C 53 FC 5D D0 37 91 05 D0 B3 EF 36 9B 6A BC X-URL: http://www.imasy.org/~ume/ X-Operating-System: FreeBSD 5.0-CURRENT Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >>>>> On Sun, 15 Jul 2001 09:19:27 -0700 >>>>> Julian Elischer 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-current" in the body of the message