diff options
-rw-r--r-- | sys/netinet/ip_icmp.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 891158083d2..4357de328dc 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.176 2018/07/11 13:06:16 claudio Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.177 2018/09/06 03:42:21 miko Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -952,20 +952,16 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid) rt = rtalloc(sintosa(&sin), RT_RESOLVE, rtableid); /* Check if the route is actually usable */ - if (!rtisvalid(rt) || (rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE))) { - rtfree(rt); - return (NULL); - } + if (!rtisvalid(rt) || (rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE))) + goto bad; /* * No PMTU for local routes and permanent neighbors, * ARP and NDP use the same expire timer as the route. */ if (ISSET(rt->rt_flags, RTF_LOCAL) || - (ISSET(rt->rt_flags, RTF_LLINFO) && rt->rt_expire == 0)) { - rtfree(rt); - return (NULL); - } + (ISSET(rt->rt_flags, RTF_LLINFO) && rt->rt_expire == 0)) + goto bad; /* If we didn't get a host route, allocate one */ if ((rt->rt_flags & RTF_HOST) == 0) { @@ -983,10 +979,8 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid) error = rtrequest(RTM_ADD, &info, rt->rt_priority, &nrt, rtableid); - if (error) { - rtfree(rt); - return (NULL); - } + if (error) + goto bad; nrt->rt_rmx = rt->rt_rmx; rtfree(rt); rt = nrt; @@ -994,12 +988,13 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid) } error = rt_timer_add(rt, icmp_mtudisc_timeout, ip_mtudisc_timeout_q, rtableid); - if (error) { - rtfree(rt); - return (NULL); - } + if (error) + goto bad; return (rt); +bad: + rtfree(rt); + return (NULL); } /* Table of common MTUs: */ |