Index | Thread | Search

From:
Alexandre Ratchov <alex@caoua.org>
Subject:
Re: Forever loop in azalia.c
To:
Ali Farzanrad <ali_farzanrad@riseup.net>
Cc:
tech@openbsd.org, kettenis@openbsd.org, ratchov@openbsd.org, martijn@openbsd.org, stsp@openbsd.org
Date:
Fri, 24 May 2024 12:32:11 +0200

Download raw body.

Thread
  • Alexandre Ratchov:

    Forever loop in azalia.c

  • On Fri, May 24, 2024 at 10:08:29AM +0000, Ali Farzanrad wrote:
    > Hi tech@
    > 
    > I found this infinite loop in azalia.c:
    > 
    > Index: azalia.c
    > ===================================================================
    > RCS file: /home/cvs/src/sys/dev/pci/azalia.c,v
    > diff -u -p -r1.287 azalia.c
    > --- azalia.c	17 May 2024 19:43:45 -0000	1.287
    > +++ azalia.c	24 May 2024 10:03:02 -0000
    > @@ -701,7 +701,7 @@ azalia_intr(void *v)
    >  	int ret = 0;
    >  
    >  	mtx_enter(&audio_lock);
    > -	for (;;) {
    > +	do {
    >  		intsts = AZ_READ_4(az, INTSTS);
    >  		if ((intsts & az->intctl) == 0 || intsts == 0xffffffff)
    >  			break;
    			^^^^^^
    
    There's a break condition. Furthermore, the loop is necessary: we've
    to loop (process events) as long as the INTSTS register is not zero
    (ie as long as there's work to do)
    
    > @@ -722,7 +722,7 @@ azalia_intr(void *v)
    >  			azalia_rirb_intr(az);
    >  			ret = 1;
    >  		}
    > -	}
    > +	} while (0);
    >  	mtx_leave(&audio_lock);
    >  	return (ret);
    >  }
    > 
    > 
    > I CCed this email to everyone related to that forever loop commit.
    > 
    > 
    > Bests,
    > Ali Farzanrad
    > 
    > 
    
    
    
  • Alexandre Ratchov:

    Forever loop in azalia.c