Re: drivers/char/random.c line 728 BUG

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Matt Mackall
Date: Wednesday, September 3, 2008 - 3:51 pm

On Wed, 2008-09-03 at 15:32 -0700, Andrew Morton wrote:

Sure, adding a local variable is fine. Though really, this shouldn't
actually improve things, that's just our compiler being sucky. And I
think it's a wash in terms of readability.


I included one, but it was terse:

 Avoid checking lock-protected entropy_count when lock isn't held.

Here's a more expansive version:

Avoid checking lock-protected entropy_count when lock isn't held. This
fixes a bug reported by and diagnosed by Aaron Straus.

This fixes a regression introduced into 2.6.26 by
 
     commit adc782dae6c4c0f6fb679a48a544cfbcd79ae3dc
     Author: Matt Mackall <mpm@selenic.com>
     Date:   Tue Apr 29 01:03:07 2008 -0700
 
         random: simplify and rename credit_entropy_store

Signed-off-by: Matt Mackall <mpm@selenic.com>
 
diff -r ddae8a8d3c6f drivers/char/random.c
--- a/drivers/char/random.c	Tue Jul 29 03:07:11 2008 +0000
+++ b/drivers/char/random.c	Wed Sep 03 17:43:18 2008 -0500
@@ -726,11 +726,10 @@
 {
 	unsigned long flags;
 
-	BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
-
 	/* Hold lock while accounting */
 	spin_lock_irqsave(&r->lock, flags);
 
+	BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
 	DEBUG_ENT("trying to extract %d bits from %s\n",
 		  nbytes * 8, r->name);

-- 
Mathematics is the supreme nostalgia of our time.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
drivers/char/random.c line 728 BUG, Aaron Straus, (Tue Aug 26, 3:59 pm)
Re: drivers/char/random.c line 728 BUG, Aaron Straus, (Thu Aug 28, 3:59 pm)
Re: drivers/char/random.c line 728 BUG, Andrew Morton, (Fri Aug 29, 12:48 pm)
Re: drivers/char/random.c line 728 BUG, Andrew Morton, (Fri Aug 29, 12:54 pm)
Re: drivers/char/random.c line 728 BUG, Aaron Straus, (Fri Aug 29, 3:31 pm)
Re: drivers/char/random.c line 728 BUG, Andrew Morton, (Fri Aug 29, 3:42 pm)
Re: drivers/char/random.c line 728 BUG, Matt Mackall, (Wed Sep 3, 11:18 am)
Re: drivers/char/random.c line 728 BUG, Aaron Straus, (Wed Sep 3, 11:28 am)
Re: drivers/char/random.c line 728 BUG, Matt Mackall, (Wed Sep 3, 3:12 pm)
Re: drivers/char/random.c line 728 BUG, Andrew Morton, (Wed Sep 3, 3:32 pm)
Re: drivers/char/random.c line 728 BUG, Matt Mackall, (Wed Sep 3, 3:51 pm)
Re: drivers/char/random.c line 728 BUG, Andrew Morton, (Wed Sep 3, 4:12 pm)