diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-09-10 06:00:38 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-09-10 06:00:38 +0000 |
commit | 08141686b4a3b35a22d2c902c9a9c74c9f589f77 (patch) | |
tree | 24a9d4051d8d0a9f13ab75e937cf0345ad9f9ae6 /sys | |
parent | 350f92bb6cea0530373316521a89c41a09bf099d (diff) |
only try and reference an ifp in if_get if we actually find one in
the map.
avoids a NULL deref jsg@ found
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index fadedd86a96..77791b35b1f 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.364 2015/09/09 16:01:10 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.365 2015/09/10 06:00:37 dlg Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1231,10 +1231,13 @@ if_get(unsigned int index) { struct ifnet *ifp = NULL; - if (index < if_indexlim) + if (index < if_indexlim) { ifp = ifindex2ifnet[index]; + if (ifp != NULL) + if_ref(ifp); + } - return (if_ref(ifp)); + return (ifp); } struct ifnet * |