mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][2.4.23-pre4] page_alloc uninitialised variable bug
@ 2003-09-13 19:39 Mikael Pettersson
  2003-09-13 23:11 ` Andrea Arcangeli
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Pettersson @ 2003-09-13 19:39 UTC (permalink / raw)
  To: marcelo.tosatti; +Cc: andrea, linux-kernel

mm/page_alloc in 2.4.23-pre4 triggers this warning:

page_alloc.c: In function `balance_classzone':
page_alloc.c:259: warning: `__freed' might be used uninitialized in this function

There is a case where balance_classzone() returns NULL and an
uninitialised value in *freed, and the caller, __alloc_pages(),
also uses the uninitialised value.

Changing balance_classzone() to not do "*freed = __freed;" in
this case is inadequate since __alloc_pages() will still look
at the bogus value. Someone needs to initialise the damn thing;
the patch below makes balance_classzone() do it.

/Mikael

--- linux-2.4.23-pre4/mm/page_alloc.c.~1~	2003-09-13 19:11:48.000000000 +0200
+++ linux-2.4.23-pre4/mm/page_alloc.c	2003-09-13 20:58:56.000000000 +0200
@@ -256,7 +256,7 @@
 static struct page * balance_classzone(zone_t * classzone, unsigned int gfp_mask, unsigned int order, int * freed)
 {
 	struct page * page = NULL;
-	int __freed;
+	int __freed = 0;
 
 	if (!(gfp_mask & __GFP_WAIT))
 		goto out;

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH][2.4.23-pre4] page_alloc uninitialised variable bug
@ 2003-09-14  9:03 Mikael Pettersson
  0 siblings, 0 replies; 3+ messages in thread
From: Mikael Pettersson @ 2003-09-14  9:03 UTC (permalink / raw)
  To: andrea; +Cc: linux-kernel, marcelo.tosatti

On Sun, 14 Sep 2003 01:11:02 +0200, Andrea Arcangeli wrote:
>this is the right cleanup for mainline to avoid the harmless compile
>time warning. Please test it so Marcelo can apply it. Sorry also for the
>delay in the watermark fixes, I finally sorted out a subtle x86-64 bug
>yesterday, so I should be able to port the watermark stuff to mainline
>early next week.
>
>--- 2.4.23pre4/mm/page_alloc.c.~1~	2003-09-13 00:08:04.000000000 +0200
>+++ 2.4.23pre4/mm/page_alloc.c	2003-09-14 01:05:24.000000000 +0200
>@@ -258,8 +258,6 @@ static struct page * balance_classzone(z
> 	struct page * page = NULL;
> 	int __freed;
> 
>-	if (!(gfp_mask & __GFP_WAIT))
>-		goto out;
> 	if (in_interrupt())
> 		BUG();

Yep this works fine.

/Mikael

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

end of thread, other threads:[~2003-09-14  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-13 19:39 [PATCH][2.4.23-pre4] page_alloc uninitialised variable bug Mikael Pettersson
2003-09-13 23:11 ` Andrea Arcangeli
2003-09-14  9:03 Mikael Pettersson

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

all inboxes | Powered by JetHome®