summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2015-09-12 11:40:05 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2015-09-12 11:40:05 +0000
commite1a55a5ff7da81942b9511d5ace0cfeb12ca0dd1 (patch)
treed7cd8cff5d3c5ecf150390e3aa500cae233024ae
parent5eb97d09125f1358db43116835bc4a9035246927 (diff)
Fix two cases where it was possible to call if_put with an uninitialized ifp
Found by jsg@ with clang
-rw-r--r--sys/netinet/ip_output.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index ac32d1573bc..1fd63d8b22b 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.293 2015/09/11 19:17:47 claudio Exp $ */
+/* $OpenBSD: ip_output.c,v 1.294 2015/09/12 11:40:04 claudio Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -89,7 +89,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags,
struct ip_moptions *imo, struct inpcb *inp, u_int32_t ipsecflowinfo)
{
struct ip *ip;
- struct ifnet *ifp;
+ struct ifnet *ifp = NULL;
struct mbuf *m = m0;
int hlen = sizeof (struct ip);
int len, error = 0;
@@ -1617,10 +1617,10 @@ ip_getmoptions(int optname, struct ip_moptions *imo, struct mbuf **mp)
addr->s_addr = INADDR_ANY;
else {
IFP_TO_IA(ifp, ia);
+ if_put(ifp);
addr->s_addr = (ia == NULL) ? INADDR_ANY
: ia->ia_addr.sin_addr.s_addr;
}
- if_put(ifp);
return (0);
case IP_MULTICAST_TTL: