public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.20-rc2] [BUGFIX] drivers/atm/firestream.c: Fix infinite recursion when alignment passed is 0.
@ 2006-12-31  2:26 Amit Choudhary
  2006-12-31  5:59 ` Mitchell Blank Jr
  2007-01-04  2:47 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Amit Choudhary @ 2006-12-31  2:26 UTC (permalink / raw)
  To: Linux Kernel

Description: Fix infinite recursion when alignment passed is 0 in function aligned_kmalloc(), in file drivers/atm/firestream.c. Also, a negative value for alignment does not make sense. Check for negative value too.
The function prototype is:
		static void __devinit *aligned_kmalloc (int size, gfp_t flags, int alignment).


Signed-off-by: Amit Choudhary <amit2030@gmail.com>

diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 9c67df5..2ba6b2e 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1385,7 +1385,7 @@ static void __devinit *aligned_kmalloc (
 
 	if (alignment <= 0x10) {
 		t = kmalloc (size, flags);
-		if ((unsigned long)t & (alignment-1)) {
+		if ((unsigned long)t & ((alignment <= 0) ? 0 : (alignment-1))) {
 			printk ("Kmalloc doesn't align things correctly! %p\n", t);
 			kfree (t);
 			return aligned_kmalloc (size, flags, alignment * 4);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-01-04  7:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-31  2:26 [PATCH 2.6.20-rc2] [BUGFIX] drivers/atm/firestream.c: Fix infinite recursion when alignment passed is 0 Amit Choudhary
2006-12-31  5:59 ` Mitchell Blank Jr
2007-01-04  7:29   ` Pekka Enberg
2007-01-04  2:47 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox