Date: Mon, 16 Jul 2001 02:30:43 +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.023043.130171162.ume@mahoroba.org> In-Reply-To: <20010716.022439.74683611.ume@mahoroba.org> References: <20010716.001314.59549708.ume@mahoroba.org> <3B51C28F.7A56D8D8@elischer.org> <20010716.022439.74683611.ume@mahoroba.org>
next in thread | previous in thread | raw e-mail | index | archive | help
ume> Index: sys/net/if.c
ume> diff -u sys/net/if.c.orig sys/net/if.c
ume> --- sys/net/if.c.orig	Mon Jul 16 01:39:34 2001
ume> +++ sys/net/if.c	Mon Jul 16 01:51:49 2001
Oops, it was wrong version.
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 (ifma == 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 (ifma == 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010716.023043.130171162.ume>
