Subject: Re: kern/14993: trying to change the media of a running tl interface causes a panic
To: None <dive@endersgame.net>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: netbsd-bugs
Date: 01/03/2002 19:04:11
On Tue, Dec 18, 2001 at 04:26:36PM -0000, dive@endersgame.net wrote:
> System: NetBSD eros.endersgame.net 1.5Z NetBSD 1.5Z (EROS) #213: Tue Dec 18 10:48:06 EST 2001 dive@eros.endersgame.net:/cvs/nblocal/sys/arch/i386/compile/EROS i386
> Architecture: i386
> Machine: i386
> >Description:
> if you have a running tl interface, and try to change the media from
> 10 to 100, or mediaopt from full to half duplex (or both), it causes a
> kernel panic. see how-to-repeat.
> >How-To-Repeat:
> This is how I verified it multiple times on my system:
> (note: tl0 is connected to a 100mbit switch, tl1 to a cable modem)
> with both interfaces configured as they are normally (tl0 at
> 100baseTX full-duplex, and tl1 at 10baseT), I ran:
> ifconfig tl0 media 10baseT
> *panic*
> it would happen if i tried to change the duplex mode, and on tl1 if
> i tried to change to 100 meg while its running.
>
> After over a day of debugging and reading through kernel source,
> I've created a patch that fixes the problem. You can now change the
> media/mediaopts while the interface is up.
> >Fix:
> --- sys.orig/dev/pci/if_tl.c Tue Nov 13 02:48:45 2001
> +++ sys/dev/pci/if_tl.c Tue Dec 18 10:57:40 2001
> @@ -1406,9 +1406,15 @@
> tl_mediachange(ifp)
> struct ifnet *ifp;
> {
> -
> - if (ifp->if_flags & IFF_UP)
> - tl_init(ifp->if_softc);
> + tl_softc_t *sc = ifp->if_softc;
> + /*
> + * this should never be called with a null pointer arg
> + */
> + if (ifp == NULL) {
> + printf("tl_mediachange: (struct ifnet *)ifp == NULL! (not changing media)\n");
> + return(0);
> + }
> + mii_mediachg(&sc->tl_mii);
> return (0);
> }
No other ethernet driver have this check, so I suspect the problem is somewhere
else. You should check why tl_mediachange() gets called with a NULL argument
at the first place.
--
Manuel Bouyer <bouyer@antioche.eu.org>
--