From owner-svn-src-all@FreeBSD.ORG Sat Sep 22 18:47:15 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0FE0B106566C; Sat, 22 Sep 2012 18:47:15 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EF3BD8FC1D; Sat, 22 Sep 2012 18:47:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8MIlEOY019459; Sat, 22 Sep 2012 18:47:14 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8MIlEwo019457; Sat, 22 Sep 2012 18:47:14 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201209221847.q8MIlEwo019457@svn.freebsd.org> From: Gleb Smirnoff Date: Sat, 22 Sep 2012 18:47:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240835 - head/sys/contrib/altq/altq X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Sep 2012 18:47:15 -0000 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 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;