* Re: mm/slab.c: linux 2.6.1 fix 2 unguarded kmalloc and a PAGE_SHIFT
@ 2004-01-25 18:16 Manfred Spraul
0 siblings, 0 replies; 3+ messages in thread
From: Manfred Spraul @ 2004-01-25 18:16 UTC (permalink / raw)
To: (Walter Harms); +Cc: Linux Kernel Mailing List
Hi Walter,
>this fixes catches 2 unguarded kmallocs() and changes a statement so that PAGE_SHIFT \
>>20 causes a warning. At least sparc64 is prepared for a PAGE_SHIFT >20.
>
>
Why should a page shift above 20 generate a warning?
The two unguarded kmallocs are obivously wrong, but I'd prefer to guard
them with __GFP_NOFAIL.
--
Manfred
^ permalink raw reply [flat|nested] 3+ messages in thread* mm/slab.c: linux 2.6.1 fix 2 unguarded kmalloc and a PAGE_SHIFT
@ 2004-01-25 14:02 Walter Harms
2004-01-25 18:11 ` Brian Gerst
0 siblings, 1 reply; 3+ messages in thread
From: Walter Harms @ 2004-01-25 14:02 UTC (permalink / raw)
To: kernel-janitors; +Cc: linux-kernel
Hi list,
this fixes catches 2 unguarded kmallocs() and changes a statement so that PAGE_SHIFT >20 causes a warning.
At least sparc64 is prepared for a PAGE_SHIFT >20.
hope that helps,
walter
--- mm/slab.c.org 2004-01-25 08:18:25.243165360 +0100
+++ mm/slab.c 2004-01-25 08:33:05.135401408 +0100
@@ -666,7 +666,7 @@
* Fragmentation resistance on low memory - only use bigger
* page orders on machines with more than 32MB of memory.
*/
- if (num_physpages > (32 << 20) >> PAGE_SHIFT)
+ if (num_physpages > (32 << (20-PAGE_SHIFT) )
slab_break_gfp_order = BREAK_GFP_ORDER_HI;
@@ -737,6 +737,10 @@
void * ptr;
ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
+
+ if (!ptr)
+ BUG();
+
local_irq_disable();
BUG_ON(ac_data(&cache_cache) != &initarray_cache.cache);
memcpy(ptr, ac_data(&cache_cache), sizeof(struct arraycache_init
));
@@ -744,6 +748,10 @@
local_irq_enable();
ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
+
+ if (!ptr)
+ BUG();
+
local_irq_disable();
BUG_ON(ac_data(malloc_sizes[0].cs_cachep) != &initarray_generic.
cache);
memcpy(ptr, ac_data(malloc_sizes[0].cs_cachep),
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: mm/slab.c: linux 2.6.1 fix 2 unguarded kmalloc and a PAGE_SHIFT
2004-01-25 14:02 Walter Harms
@ 2004-01-25 18:11 ` Brian Gerst
0 siblings, 0 replies; 3+ messages in thread
From: Brian Gerst @ 2004-01-25 18:11 UTC (permalink / raw)
To: WHarms; +Cc: kernel-janitors, linux-kernel
(Walter Harms) wrote:
> Hi list,
> this fixes catches 2 unguarded kmallocs() and changes a statement so that PAGE_SHIFT >20 causes a warning.
> At least sparc64 is prepared for a PAGE_SHIFT >20.
>
> hope that helps,
> walter
>
>
> --- mm/slab.c.org 2004-01-25 08:18:25.243165360 +0100
> +++ mm/slab.c 2004-01-25 08:33:05.135401408 +0100
> @@ -666,7 +666,7 @@
> * Fragmentation resistance on low memory - only use bigger
> * page orders on machines with more than 32MB of memory.
> */
> - if (num_physpages > (32 << 20) >> PAGE_SHIFT)
> + if (num_physpages > (32 << (20-PAGE_SHIFT) )
> slab_break_gfp_order = BREAK_GFP_ORDER_HI;
>
>
> @@ -737,6 +737,10 @@
> void * ptr;
>
> ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
> +
> + if (!ptr)
> + BUG();
> +
> local_irq_disable();
> BUG_ON(ac_data(&cache_cache) != &initarray_cache.cache);
> memcpy(ptr, ac_data(&cache_cache), sizeof(struct arraycache_init
> ));
> @@ -744,6 +748,10 @@
> local_irq_enable();
>
> ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
> +
> + if (!ptr)
> + BUG();
> +
> local_irq_disable();
> BUG_ON(ac_data(malloc_sizes[0].cs_cachep) != &initarray_generic.
> cache);
> memcpy(ptr, ac_data(malloc_sizes[0].cs_cachep),
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
BUG_ON(!ptr) would be better.
--
Brian Gerst
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-01-25 18:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-25 18:16 mm/slab.c: linux 2.6.1 fix 2 unguarded kmalloc and a PAGE_SHIFT Manfred Spraul
-- strict thread matches above, loose matches on Subject: below --
2004-01-25 14:02 Walter Harms
2004-01-25 18:11 ` Brian Gerst
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.