svn commit: r240824 - head/sys/contrib/altq/altq

Gleb Smirnoff glebius at FreeBSD.org
Sat Sep 22 12:49:37 UTC 2012


Author: glebius
Date: Sat Sep 22 12:49:36 2012
New Revision: 240824
URL: http://svn.freebsd.org/changeset/base/240824

Log:
  Convert more M_WAITOK malloc() to M_NOWAIT.
  
  Reported by:	Kim Culhan <w8hdkim gmail.com>

Modified:
  head/sys/contrib/altq/altq/altq_priq.c
  head/sys/contrib/altq/altq/altq_red.c
  head/sys/contrib/altq/altq/altq_rio.c

Modified: head/sys/contrib/altq/altq/altq_priq.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_priq.c	Sat Sep 22 12:42:51 2012	(r240823)
+++ head/sys/contrib/altq/altq/altq_priq.c	Sat Sep 22 12:49:36 2012	(r240824)
@@ -362,8 +362,9 @@ priq_class_create(struct priq_if *pif, i
 		if (flags & PRCF_RIO) {
 			cl->cl_red = (red_t *)rio_alloc(0, NULL,
 						red_flags, red_pkttime);
-			if (cl->cl_red != NULL)
-				qtype(cl->cl_q) = Q_RIO;
+			if (cl->cl_red == NULL)
+				goto err_ret;
+			qtype(cl->cl_q) = Q_RIO;
 		} else
 #endif
 		if (flags & PRCF_RED) {
@@ -371,8 +372,9 @@ priq_class_create(struct priq_if *pif, i
 			    qlimit(cl->cl_q) * 10/100,
 			    qlimit(cl->cl_q) * 30/100,
 			    red_flags, red_pkttime);
-			if (cl->cl_red != NULL)
-				qtype(cl->cl_q) = Q_RED;
+			if (cl->cl_red == NULL)
+				goto err_ret;
+			qtype(cl->cl_q) = Q_RED;
 		}
 	}
 #endif /* ALTQ_RED */

Modified: head/sys/contrib/altq/altq/altq_red.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_red.c	Sat Sep 22 12:42:51 2012	(r240823)
+++ head/sys/contrib/altq/altq/altq_red.c	Sat Sep 22 12:49:36 2012	(r240824)
@@ -231,10 +231,9 @@ red_alloc(int weight, int inv_pmax, int 
 	int	 w, i;
 	int	 npkts_per_sec;
 
-	rp = malloc(sizeof(red_t), M_DEVBUF, M_WAITOK);
+	rp = malloc(sizeof(red_t), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (rp == NULL)
 		return (NULL);
-	bzero(rp, sizeof(red_t));
 
 	rp->red_avg = 0;
 	rp->red_idle = 1;

Modified: head/sys/contrib/altq/altq/altq_rio.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_rio.c	Sat Sep 22 12:42:51 2012	(r240823)
+++ head/sys/contrib/altq/altq/altq_rio.c	Sat Sep 22 12:49:36 2012	(r240824)
@@ -204,10 +204,9 @@ rio_alloc(int weight, struct redparams *
 	int	 w, i;
 	int	 npkts_per_sec;
 
-	rp = malloc(sizeof(rio_t), M_DEVBUF, M_WAITOK);
+	rp = malloc(sizeof(rio_t), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (rp == NULL)
 		return (NULL);
-	bzero(rp, sizeof(rio_t));
 
 	rp->rio_flags = flags;
 	if (pkttime == 0)


More information about the svn-src-all mailing list