Subject: kern/25061: possible infinite loop in mii readreg routines
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: netbsd-bugs
Date: 04/06/2004 00:02:09
>Number:         25061
>Category:       kern
>Synopsis:       possible infinite loop in mii readreg routines
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 05 14:03:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 2.0C, april 2004 sources
>Organization:
Wasabi Systems
>Environment:
	Architecture: any
	Machine: any
>Description:

        Some mii readreg routines in dev/pci/if_sip.c can sometimes lead
        to an infinite kernel loop.

        Two examples are:

        do {
                enphy = bus_space_read_4(sc->sc_st, sc->sc_sh, SIP_ENPHY);
        } while (enphy & ENPHY_ACCESS);

        and

        do {
                val = bus_space_read_4(sc->sc_st, sc->sc_sh, SIP_NS_PHY(reg));
        } while (reg == MII_BMSR && val == 0);

>How-To-Repeat:

	Code inspection (or try to use a buggy bus_space implementation!).

>Fix:

        Add timeouts like (to pick two at random) dev/pci/if_bge.c or
        arch/mips/alchemy/dev/if_aumac.c.  Should check other drivers as
        well.
>Release-Note:
>Audit-Trail:
>Unformatted: