Date: Sun, 23 Sep 2001 05:36:17 -0400 (EDT) From: "Matthew N. Dodd" <winter@jurai.net> To: freebsd-net@freebsd.org Subject: review request. Message-ID: <Pine.BSF.4.21.0109230534170.3806-200000@sasami.jurai.net>
index | next in thread | raw e-mail
[-- Attachment #1 --] sys/net/if.c and bpf.c have problems with if_detach() and bpfdetach() when they are called with a struct ifnet that has not had if_attach() and bpfattach() called on it. Null pointer reference -> *boom* etc. This patch fixes the test already present in bpfdetach() and adds a test to if_detach(). Thanks. -- | Matthew N. Dodd | '78 Datsun 280Z | '75 Volvo 164E | FreeBSD/NetBSD | | winter@jurai.net | 2 x '84 Volvo 245DL | ix86,sparc,pmax | | http://www.jurai.net/~winter | For Great Justice! | ISO8802.5 4ever | [-- Attachment #2 --] Index: if.c =================================================================== RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.116 diff -u -r1.116 if.c --- if.c 18 Sep 2001 17:41:42 -0000 1.116 +++ if.c 23 Sep 2001 09:17:11 -0000 @@ -248,6 +248,14 @@ * Remove routes and flush queues. */ s = splnet(); + + if (ifp->if_index == 0) { + splx(s); + printf("if_detach: %s%d was not attached\n", ifp->if_name, + ifp->if_unit); + return; + } + if_down(ifp); /* Index: bpf.c =================================================================== RCS file: /cvs/src/sys/net/bpf.c,v retrieving revision 1.82 diff -u -r1.82 bpf.c --- bpf.c 21 Sep 2001 22:46:54 -0000 1.82 +++ bpf.c 23 Sep 2001 03:58:04 -0000 @@ -1264,7 +1264,7 @@ } /* Interface wasn't attached */ - if (bp->bif_ifp == NULL) { + if (bp == NULL) { mtx_unlock(&bpf_mtx); printf("bpfdetach: %s%d was not attached\n", ifp->if_name, ifp->if_unit);help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0109230534170.3806-200000>
