Date: Sat, 22 Sep 2012 18:47:14 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r240835 - head/sys/contrib/altq/altq Message-ID: <201209221847.q8MIlEwo019457@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209221847.q8MIlEwo019457>