diff options
author | glebius <glebius@FreeBSD.org> | 2012-09-22 18:47:14 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2012-09-22 18:47:14 +0000 |
commit | b44d6974910511214e518598dd223b3089f25574 (patch) | |
tree | c82134b66ec6d1c1842c9fd3ac1bf620a096b4f1 | |
parent | 7ea6c49b3385486613bed5ff6bbbbc4e0df9af2f (diff) | |
download | FreeBSD-src-b44d6974910511214e518598dd223b3089f25574.zip FreeBSD-src-b44d6974910511214e518598dd223b3089f25574.tar.gz |
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>
-rw-r--r-- | sys/contrib/altq/altq/altq_red.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/contrib/altq/altq/altq_red.c b/sys/contrib/altq/altq/altq_red.c index b589454..be9eff8 100644 --- a/sys/contrib/altq/altq/altq_red.c +++ b/sys/contrib/altq/altq/altq_red.c @@ -235,6 +235,13 @@ red_alloc(int weight, int inv_pmax, int th_min, int th_max, int flags, 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 th_min, int th_max, int flags, 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; |