aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2018-05-25 19:48:26 +0000
committerMatt Macy <mmacy@FreeBSD.org>2018-05-25 19:48:26 +0000
commit9379029a9258d92f28c9721a5fcda5309207872d (patch)
tree2f8fa67da827ab822e6bcba3b46ee32bec50ef45 /sys/net
parent75a315f6d2a31c61cb3f3da58e44be090c663ff7 (diff)
downloadsrc-9379029a9258d92f28c9721a5fcda5309207872d.tar.gz
src-9379029a9258d92f28c9721a5fcda5309207872d.zip
rtrequest1_fib: we need to always bump the ifaddr refcount when we take a reference from
an rtentry. r334118 introduced a case when this was not done. While we're here make the intent more obvious by moving the refcount bump down to when we know we'll actually need it. Reported by: markj
Notes
Notes: svn path=/head/; revision=334222
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/route.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index e51d50e940aa..1b5bf39d16b3 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1586,12 +1586,9 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt,
error = rt_getifa_fib(info, fibnum);
if (error)
return (error);
- } else
- ifa_ref(info->rti_ifa);
- ifa = info->rti_ifa;
+ }
rt = uma_zalloc(V_rtzone, M_NOWAIT);
if (rt == NULL) {
- ifa_free(ifa);
return (ENOBUFS);
}
rt->rt_flags = RTF_UP | flags;
@@ -1600,7 +1597,6 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt,
* Add the gateway. Possibly re-malloc-ing the storage for it.
*/
if ((error = rt_setgate(rt, dst, gateway)) != 0) {
- ifa_free(ifa);
uma_zfree(V_rtzone, rt);
return (error);
}
@@ -1623,6 +1619,8 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt,
* This moved from below so that rnh->rnh_addaddr() can
* examine the ifa and ifa->ifa_ifp if it so desires.
*/
+ ifa = info->rti_ifa;
+ ifa_ref(ifa);
rt->rt_ifa = ifa;
rt->rt_ifp = ifa->ifa_ifp;
rt->rt_weight = 1;