Author: glebius
Date: Sat Sep 22 18:47:14 2012
New Revision: 240835
URL: http://svn.freebsd.org/changeset/base/240835

Log:
  Use M_NOWAIT in wtab_alloc(), too. Convert panic() to
  a soft failure here. wtab_alloc() is used by red_alloc(),
  which can fail.
  
  Reported by:  Kim Culhan <w8hdkim gmail.com>

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

Modified: head/sys/contrib/altq/altq/altq_red.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_red.c       Sat Sep 22 17:49:25 2012        
(r240834)
+++ head/sys/contrib/altq/altq/altq_red.c       Sat Sep 22 18:47:14 2012        
(r240835)
@@ -235,6 +235,13 @@ red_alloc(int weight, int inv_pmax, int 
        if (rp == NULL)
                return (NULL);
 
+       /* allocate weight table */
+       rp->red_wtab = wtab_alloc(rp->red_weight);
+       if (rp->red_wtab == NULL) {
+               free(rp, M_DEVBUF);
+               return (NULL);
+       }
+
        rp->red_avg = 0;
        rp->red_idle = 1;
 
@@ -301,9 +308,6 @@ red_alloc(int weight, int inv_pmax, int 
        rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin)
                         * rp->red_inv_pmax) << FP_SHIFT;
 
-       /* allocate weight table */
-       rp->red_wtab = wtab_alloc(rp->red_weight);
-
        microtime(&rp->red_last);
        return (rp);
 }
@@ -638,10 +642,9 @@ wtab_alloc(int weight)
                        return (w);
                }
 
-       w = malloc(sizeof(struct wtab), M_DEVBUF, M_WAITOK);
+       w = malloc(sizeof(struct wtab), M_DEVBUF, M_NOWAIT | M_ZERO);
        if (w == NULL)
-               panic("wtab_alloc: malloc failed!");
-       bzero(w, sizeof(struct wtab));
+               return (NULL);
        w->w_weight = weight;
        w->w_refcount = 1;
        w->w_next = wtab_list;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to