summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2005-03-26 22:20:22 +0000
committersam <sam@FreeBSD.org>2005-03-26 22:20:22 +0000
commitd2c3d0b002bb9dd56788d822f8687f3c1b06ca04 (patch)
tree3ea2f1a48fa85ebf9fa59a229372ed563c36e2f2 /sys
parentab9a9d1c2545d1f3578540824f2e00737766310f (diff)
downloadFreeBSD-src-d2c3d0b002bb9dd56788d822f8687f3c1b06ca04.zip
FreeBSD-src-d2c3d0b002bb9dd56788d822f8687f3c1b06ca04.tar.gz
deal with malloc failures
Noticed by: Coverity Prevent analysis tool Together with: mdodd
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/igmp.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 27cff536..2c68e3c 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -151,10 +151,11 @@ find_rti(struct ifnet *ifp)
return rti;
}
}
- /*
- * XXXRW: return value of malloc not checked, despite M_NOWAIT.
- */
MALLOC(rti, struct router_info *, sizeof *rti, M_IGMP, M_NOWAIT);
+ if (rti == NULL) {
+ IGMP_PRINTF( "[igmp.c, _find_rti] --> no memory for entry\n");
+ return NULL;
+ }
rti->rti_ifp = ifp;
rti->rti_type = IGMP_V2_ROUTER;
rti->rti_time = 0;
@@ -245,6 +246,11 @@ igmp_input(register struct mbuf *m, int off)
mtx_lock(&igmp_mtx);
rti = find_rti(ifp);
+ if (rti == NULL) {
+ mtx_unlock(&igmp_mtx);
+ m_freem(m);
+ return;
+ }
rti->rti_type = IGMP_V1_ROUTER;
rti->rti_time = 0;
mtx_unlock(&igmp_mtx);
@@ -369,11 +375,14 @@ igmp_joingroup(struct in_multi *inm)
mtx_lock(&igmp_mtx);
inm->inm_rti = find_rti(inm->inm_ifp);
mtx_unlock(&igmp_mtx);
- igmp_sendpkt(inm, inm->inm_rti->rti_type, 0);
- inm->inm_timer = IGMP_RANDOM_DELAY(
+ if (inm->inm_rti != NULL) {
+ igmp_sendpkt(inm, inm->inm_rti->rti_type, 0);
+ inm->inm_timer = IGMP_RANDOM_DELAY(
IGMP_MAX_HOST_REPORT_DELAY*PR_FASTHZ);
- inm->inm_state = IGMP_IREPORTEDLAST;
- igmp_timers_are_running = 1;
+ inm->inm_state = IGMP_IREPORTEDLAST;
+ igmp_timers_are_running = 1;
+ }
+ /* XXX handling of failure case? */
}
splx(s);
}
OpenPOWER on IntegriCloud