Re: random(4) related panic: sleeping without a mutex

From: Mark Murray <markm_at_FreeBSD.ORG>
Date: Mon, 12 Apr 2004 00:59:23 +0100
"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

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
_at__at_ -103,25 +103,28 _at__at_
 {
 	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);
 }
 
Received on Sun Apr 11 2004 - 15:00:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:50 UTC