Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Apr 2004 00:59:23 +0100
From:      Mark Murray <markm@FreeBSD.ORG>
To:        "Simon L. Nielsen" <simon@FreeBSD.ORG>
Cc:        freebsd-current@FreeBSD.ORG
Subject:   Re: random(4) related panic: sleeping without a mutex 
Message-ID:  <200404112359.i3BNxNIn080714@grimreaper.grondar.org>
In-Reply-To: Your message of "Sun, 11 Apr 2004 23:54:36 %2B0200." <20040411215436.GB881@zaphod.nitro.dk> 

next in thread | previous in thread | raw e-mail | index | archive | help
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <80711.1081727938.1@grondar.org>

"Simon L. Nielsen" writes:
> I getting the following panic on my Soekris Net4801 box right after init
> has been started:
> 
> Mounting root from ufs:/dev/ad0s1a
> start_init: trying /sbin/init
> panic: sleeping without a mutex
> at line 144 in file /data/nanobsd/src/sys/kern/kern_synch.c
> Debugger("panic")
> Stopped at      Debugger+0x45:  xchgl   %ebx,in_Debugger.0

Could you please try the enclosed patch?

M
--
Mark Murray
iumop ap!sdn w,I idlaH

------- =_aaaaaaaaaa0
Content-Type: text/plain; file="randomdev.c.diff"; charset="us-ascii"
Content-ID: <80711.1081727938.2@grondar.org>
Content-Description: randomdev.c.diff

Index: randomdev.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/random/randomdev.c,v
retrieving revision 1.49
diff -u -d -r1.49 randomdev.c
--- randomdev.c	9 Apr 2004 15:47:09 -0000	1.49
+++ randomdev.c	11 Apr 2004 19:08:03 -0000
@@ -103,25 +103,28 @@
 {
 	int c, error = 0;
 
+	mtx_lock(&random_systat.lock);
+
 	/* Blocking logic */
 	while (!random_systat.seeded && !error) {
 		if (flag & IO_NDELAY)
 			error = EWOULDBLOCK;
 		else
-			error = tsleep(&random_systat,
+			error = msleep(&random_systat, &random_systat.lock,
 			    PUSER | PCATCH, "block", 0);
 	}
 
 	/* The actual read */
 	if (!error) {
-		mtx_lock(&random_systat.lock);
 		while (uio->uio_resid > 0 && !error) {
 			c = MIN(uio->uio_resid, PAGE_SIZE);
 			c = (*random_systat.read)(random_buf, c);
 			error = uiomove(random_buf, c, uio);
 		}
-		mtx_unlock(&random_systat.lock);
 	}
+
+	mtx_unlock(&random_systat.lock);
+
 	return (error);
 }
 

------- =_aaaaaaaaaa0--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404112359.i3BNxNIn080714>