diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2008-05-08 15:22:03 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2008-05-08 15:22:03 +0000 |
commit | e559e06f550eb2d3bacb277d58b1e3004ced232c (patch) | |
tree | b37708b8ba08d19bb08f0c13bba27789357995b8 /sys/altq | |
parent | 3c0c2d805016b41bbe5e0711ab423a2a97572a9f (diff) |
do not check malloc return value against NULL, as M_WAITOK is used
ok kjc@
Diffstat (limited to 'sys/altq')
-rw-r--r-- | sys/altq/altq_cbq.c | 4 | ||||
-rw-r--r-- | sys/altq/altq_cdnr.c | 4 | ||||
-rw-r--r-- | sys/altq/altq_hfsc.c | 26 | ||||
-rw-r--r-- | sys/altq/altq_priq.c | 30 | ||||
-rw-r--r-- | sys/altq/altq_red.c | 6 | ||||
-rw-r--r-- | sys/altq/altq_rio.c | 4 | ||||
-rw-r--r-- | sys/altq/altq_rmclass.c | 14 | ||||
-rw-r--r-- | sys/altq/altq_subr.c | 4 |
8 files changed, 14 insertions, 78 deletions
diff --git a/sys/altq/altq_cbq.c b/sys/altq/altq_cbq.c index a17eb403de1..9b52a1bbce9 100644 --- a/sys/altq/altq_cbq.c +++ b/sys/altq/altq_cbq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_cbq.c,v 1.23 2007/09/13 20:40:02 chl Exp $ */ +/* $OpenBSD: altq_cbq.c,v 1.24 2008/05/08 15:22:02 chl Exp $ */ /* $KAME: altq_cbq.c,v 1.9 2000/12/14 08:12:45 thorpej Exp $ */ /* @@ -215,8 +215,6 @@ cbq_add_altq(struct pf_altq *a) /* allocate and initialize cbq_state_t */ cbqp = malloc(sizeof(cbq_state_t), M_DEVBUF, M_WAITOK|M_ZERO); - if (cbqp == NULL) - return (ENOMEM); CALLOUT_INIT(&cbqp->cbq_callout); cbqp->cbq_qlen = 0; cbqp->ifnp.ifq_ = &ifp->if_snd; /* keep the ifq */ diff --git a/sys/altq/altq_cdnr.c b/sys/altq/altq_cdnr.c index e4455ae646d..2bf83f7c474 100644 --- a/sys/altq/altq_cdnr.c +++ b/sys/altq/altq_cdnr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_cdnr.c,v 1.9 2008/04/20 07:05:51 deraadt Exp $ */ +/* $OpenBSD: altq_cdnr.c,v 1.10 2008/05/08 15:22:02 chl Exp $ */ /* $KAME: altq_cdnr.c,v 1.8 2000/12/14 08:12:45 thorpej Exp $ */ /* @@ -285,8 +285,6 @@ cdnr_cballoc(top, type, input_func) } cb = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO); - if (cb == NULL) - return (NULL); cb->cb_len = size; cb->cb_type = type; diff --git a/sys/altq/altq_hfsc.c b/sys/altq/altq_hfsc.c index 39f25736889..f3771af6e67 100644 --- a/sys/altq/altq_hfsc.c +++ b/sys/altq/altq_hfsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_hfsc.c,v 1.25 2007/09/13 20:40:02 chl Exp $ */ +/* $OpenBSD: altq_hfsc.c,v 1.26 2008/05/08 15:22:02 chl Exp $ */ /* $KAME: altq_hfsc.c,v 1.17 2002/11/29 07:48:33 kjc Exp $ */ /* @@ -155,14 +155,8 @@ hfsc_add_altq(struct pf_altq *a) return (ENODEV); hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_WAITOK|M_ZERO); - if (hif == NULL) - return (ENOMEM); hif->hif_eligible = ellist_alloc(); - if (hif->hif_eligible == NULL) { - free(hif, M_DEVBUF); - return (ENOMEM); - } hif->hif_ifq = &ifp->if_snd; @@ -348,16 +342,10 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, #endif cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_WAITOK|M_ZERO); - if (cl == NULL) - return (NULL); cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_WAITOK|M_ZERO); - if (cl->cl_q == NULL) - goto err_ret; cl->cl_actc = actlist_alloc(); - if (cl->cl_actc == NULL) - goto err_ret; if (qlimit == 0) qlimit = 50; /* use default */ @@ -395,15 +383,13 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, 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; + qtype(cl->cl_q) = Q_RED; } #ifdef ALTQ_RIO else { cl->cl_red = (red_t *)rio_alloc(0, NULL, red_flags, red_pkttime); - if (cl->cl_red != NULL) - qtype(cl->cl_q) = Q_RIO; + qtype(cl->cl_q) = Q_RIO; } #endif } @@ -412,8 +398,6 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) { cl->cl_rsc = malloc(sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); - if (cl->cl_rsc == NULL) - goto err_ret; sc2isc(rsc, cl->cl_rsc); rtsc_init(&cl->cl_deadline, cl->cl_rsc, 0, 0); rtsc_init(&cl->cl_eligible, cl->cl_rsc, 0, 0); @@ -421,16 +405,12 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0)) { cl->cl_fsc = malloc(sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); - if (cl->cl_fsc == NULL) - goto err_ret; sc2isc(fsc, cl->cl_fsc); rtsc_init(&cl->cl_virtual, cl->cl_fsc, 0, 0); } if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0)) { cl->cl_usc = malloc(sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); - if (cl->cl_usc == NULL) - goto err_ret; sc2isc(usc, cl->cl_usc); rtsc_init(&cl->cl_ulimit, cl->cl_usc, 0, 0); } diff --git a/sys/altq/altq_priq.c b/sys/altq/altq_priq.c index 37de8bf1cf3..b6628c627f6 100644 --- a/sys/altq/altq_priq.c +++ b/sys/altq/altq_priq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_priq.c,v 1.21 2007/09/13 20:40:02 chl Exp $ */ +/* $OpenBSD: altq_priq.c,v 1.22 2008/05/08 15:22:02 chl Exp $ */ /* $KAME: altq_priq.c,v 1.1 2000/10/18 09:15:23 kjc Exp $ */ /* * Copyright (C) 2000 @@ -94,8 +94,6 @@ priq_add_altq(struct pf_altq *a) return (ENODEV); pif = malloc(sizeof(struct priq_if), M_DEVBUF, M_WAITOK|M_ZERO); - if (pif == NULL) - return (ENOMEM); pif->pif_bandwidth = a->ifbandwidth; pif->pif_maxpri = -1; pif->pif_ifq = &ifp->if_snd; @@ -266,13 +264,9 @@ priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags, int qid) } else { cl = malloc(sizeof(struct priq_class), M_DEVBUF, M_WAITOK|M_ZERO); - if (cl == NULL) - return (NULL); cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_WAITOK|M_ZERO); - if (cl->cl_q == NULL) - goto err_ret; } pif->pif_classes[pri] = cl; @@ -310,8 +304,7 @@ priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags, int qid) 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; + qtype(cl->cl_q) = Q_RIO; } else #endif if (flags & PRCF_RED) { @@ -319,29 +312,12 @@ priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags, int qid) 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; + qtype(cl->cl_q) = Q_RED; } } #endif /* ALTQ_RED */ return (cl); - - err_ret: - if (cl->cl_red != NULL) { -#ifdef ALTQ_RIO - if (q_is_rio(cl->cl_q)) - rio_destroy((rio_t *)cl->cl_red); -#endif -#ifdef ALTQ_RED - if (q_is_red(cl->cl_q)) - red_destroy(cl->cl_red); -#endif - } - if (cl->cl_q != NULL) - free(cl->cl_q, M_DEVBUF); - free(cl, M_DEVBUF); - return (NULL); } static int diff --git a/sys/altq/altq_red.c b/sys/altq/altq_red.c index 57e97600073..6eb9c683515 100644 --- a/sys/altq/altq_red.c +++ b/sys/altq/altq_red.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_red.c,v 1.15 2008/04/20 07:05:52 deraadt Exp $ */ +/* $OpenBSD: altq_red.c,v 1.16 2008/05/08 15:22:02 chl Exp $ */ /* $KAME: altq_red.c,v 1.10 2002/04/03 05:38:51 kjc Exp $ */ /* @@ -163,8 +163,6 @@ red_alloc(int weight, int inv_pmax, int th_min, int th_max, int flags, int npkts_per_sec; rp = malloc(sizeof(red_t), M_DEVBUF, M_WAITOK|M_ZERO); - if (rp == NULL) - return (NULL); rp->red_avg = 0; rp->red_idle = 1; @@ -534,8 +532,6 @@ wtab_alloc(int weight) } w = malloc(sizeof(struct wtab), M_DEVBUF, M_WAITOK|M_ZERO); - if (w == NULL) - panic("wtab_alloc: malloc failed!"); w->w_weight = weight; w->w_refcount = 1; w->w_next = wtab_list; diff --git a/sys/altq/altq_rio.c b/sys/altq/altq_rio.c index 92bfda614ae..e3d4207a0c9 100644 --- a/sys/altq/altq_rio.c +++ b/sys/altq/altq_rio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_rio.c,v 1.11 2007/09/13 20:40:02 chl Exp $ */ +/* $OpenBSD: altq_rio.c,v 1.12 2008/05/08 15:22:02 chl Exp $ */ /* $KAME: altq_rio.c,v 1.8 2000/12/14 08:12:46 thorpej Exp $ */ /* @@ -173,8 +173,6 @@ rio_alloc(int weight, struct redparams *params, int flags, int pkttime) int npkts_per_sec; rp = malloc(sizeof(rio_t), M_DEVBUF, M_WAITOK|M_ZERO); - if (rp == NULL) - return (NULL); rp->rio_flags = flags; if (pkttime == 0) diff --git a/sys/altq/altq_rmclass.c b/sys/altq/altq_rmclass.c index dd58fea4807..45a7e8d36c8 100644 --- a/sys/altq/altq_rmclass.c +++ b/sys/altq/altq_rmclass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_rmclass.c,v 1.14 2008/04/20 07:05:52 deraadt Exp $ */ +/* $OpenBSD: altq_rmclass.c,v 1.15 2008/05/08 15:22:02 chl Exp $ */ /* $KAME: altq_rmclass.c,v 1.10 2001/02/09 07:20:40 kjc Exp $ */ /* @@ -201,14 +201,8 @@ rmc_newclass(int pri, struct rm_ifdat *ifd, u_int nsecPerByte, #endif cl = malloc(sizeof(struct rm_class), M_DEVBUF, M_WAITOK|M_ZERO); - if (cl == NULL) - return (NULL); CALLOUT_INIT(&cl->callout_); cl->q_ = malloc(sizeof(class_queue_t), M_DEVBUF, M_WAITOK|M_ZERO); - if (cl->q_ == NULL) { - free(cl, M_DEVBUF); - return (NULL); - } /* * Class initialization. @@ -270,15 +264,13 @@ rmc_newclass(int pri, struct rm_ifdat *ifd, u_int nsecPerByte, qlimit(cl->q_) * 10/100, qlimit(cl->q_) * 30/100, red_flags, red_pkttime); - if (cl->red_ != NULL) - qtype(cl->q_) = Q_RED; + qtype(cl->q_) = Q_RED; } #ifdef ALTQ_RIO else { cl->red_ = (red_t *)rio_alloc(0, NULL, red_flags, red_pkttime); - if (cl->red_ != NULL) - qtype(cl->q_) = Q_RIO; + qtype(cl->q_) = Q_RIO; } #endif } diff --git a/sys/altq/altq_subr.c b/sys/altq/altq_subr.c index 1bcd7d0483f..2213f16b5d6 100644 --- a/sys/altq/altq_subr.c +++ b/sys/altq/altq_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_subr.c,v 1.24 2007/12/11 00:30:14 mikeb Exp $ */ +/* $OpenBSD: altq_subr.c,v 1.25 2008/05/08 15:22:02 chl Exp $ */ /* $KAME: altq_subr.c,v 1.11 2002/01/11 08:11:49 kjc Exp $ */ /* @@ -274,8 +274,6 @@ tbr_set(ifq, profile) } tbr = malloc(sizeof(struct tb_regulator), M_DEVBUF, M_WAITOK|M_ZERO); - if (tbr == NULL) - return (ENOMEM); tbr->tbr_rate = TBR_SCALE(profile->rate / 8) / machclk_freq; tbr->tbr_depth = TBR_SCALE(profile->depth); |