summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2021-09-07 16:07:47 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2021-09-07 16:07:47 +0000
commit8ab24c2bafcefda55eb55cd2cf1f81f3436e34a1 (patch)
treea3c75afa2f30bc63bfa3b235a520c80f9e4c59db /sys/net
parenta7fb1673780336c62922928999b8d7cfff8e6c3d (diff)
Fix NULL pointer dereference introduced by previous commit.
Reported-by: syzbot+684597dbbb9b516e76ae@syzkaller.appspotmail.com ok mpi@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/rtsock.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 8a8a74f5a51..7cdd8fe4881 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.320 2021/09/07 09:56:00 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.321 2021/09/07 16:07:46 mvs Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -1032,14 +1032,6 @@ rtm_output(struct rt_msghdr *rtm, struct rtentry **prt,
rt = NULL;
}
- ifp = if_get(rt->rt_ifidx);
- if (ifp == NULL) {
- rtfree(rt);
- rt = NULL;
- error = ESRCH;
- break;
- }
-
/*
* If RTAX_GATEWAY is the argument we're trying to
* change, try to find a compatible route.
@@ -1068,6 +1060,14 @@ rtm_output(struct rt_msghdr *rtm, struct rtentry **prt,
break;
}
+ ifp = if_get(rt->rt_ifidx);
+ if (ifp == NULL) {
+ rtfree(rt);
+ rt = NULL;
+ error = ESRCH;
+ break;
+ }
+
/*
* RTM_CHANGE needs a perfect match.
*/