summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/raw_ip6.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2005-03-29 01:26:27 +0000
committersam <sam@FreeBSD.org>2005-03-29 01:26:27 +0000
commita2c73279e6a79b29118791d4b171c1150dc0c948 (patch)
treeaab82eb8aba5456e50afd2465a2732edcd0d36a6 /sys/netinet6/raw_ip6.c
parent0f999925e827e39fc83c5bf1abc2ab5b7e126f80 (diff)
downloadFreeBSD-src-a2c73279e6a79b29118791d4b171c1150dc0c948.zip
FreeBSD-src-a2c73279e6a79b29118791d4b171c1150dc0c948.tar.gz
check for malloc failure (also move malloc up to simplify error recovery)
Noticed by: Coverity Prevent analysis tool Reviewed by: gnn
Diffstat (limited to 'sys/netinet6/raw_ip6.c')
-rw-r--r--sys/netinet6/raw_ip6.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 2ba558f..cf0e548 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -560,6 +560,7 @@ static int
rip6_attach(struct socket *so, int proto, struct thread *td)
{
struct inpcb *inp;
+ struct icmp6_filter *filter;
int error, s;
INP_INFO_WLOCK(&ripcbinfo);
@@ -577,11 +578,16 @@ rip6_attach(struct socket *so, int proto, struct thread *td)
INP_INFO_WUNLOCK(&ripcbinfo);
return error;
}
+ MALLOC(filter, struct icmp6_filter *,
+ sizeof(struct icmp6_filter), M_PCB, M_NOWAIT);
+ if (filter == NULL)
+ return ENOMEM;
s = splnet();
error = in_pcballoc(so, &ripcbinfo, "raw6inp");
splx(s);
if (error) {
INP_INFO_WUNLOCK(&ripcbinfo);
+ FREE(filter, M_PCB);
return error;
}
inp = (struct inpcb *)so->so_pcb;
@@ -591,8 +597,7 @@ rip6_attach(struct socket *so, int proto, struct thread *td)
inp->in6p_ip6_nxt = (long)proto;
inp->in6p_hops = -1; /* use kernel default */
inp->in6p_cksum = -1;
- MALLOC(inp->in6p_icmp6filt, struct icmp6_filter *,
- sizeof(struct icmp6_filter), M_PCB, M_NOWAIT);
+ inp->in6p_icmp6filt = filter;
ICMP6_FILTER_SETPASSALL(inp->in6p_icmp6filt);
INP_UNLOCK(inp);
return 0;
OpenPOWER on IntegriCloud