* [PATCH 2.6.26-rc4] Fix nesting error checking in arch/x86/mm/ioremap.c
@ 2008-05-27 5:49 Mika Kukkonen
2008-05-27 8:00 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Mika Kukkonen @ 2008-05-27 5:49 UTC (permalink / raw)
To: linux-kernel; +Cc: torvalds, arjan
The discussion about latest -rc reminded me of this patch (probably
unrelated but anyway). With "-Wextra" I get following warning:
CC arch/x86/mm/ioremap.o
arch/x86/mm/ioremap.c: In function 'early_iounmap':
arch/x86/mm/ioremap.c:599: warning: comparison of unsigned expression < 0 is always false
Following patch avoids potential underflow and actually does the WARN().
Signed-off-by: Mika Kukkonen <mikukkon@iki.fi>
---
arch/x86/mm/ioremap.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 71bb315..78667f4 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -595,8 +595,12 @@ void __init early_iounmap(void *addr, unsigned long size)
enum fixed_addresses idx;
unsigned int nesting;
- nesting = --early_ioremap_nested;
- WARN_ON(nesting < 0);
+ if (early_ioremap_nested)
+ nesting = --early_ioremap_nested;
+ else {
+ nesting = 0;
+ WARN_ON(1);
+ }
if (early_ioremap_debug) {
printk(KERN_INFO "early_iounmap(%p, %08lx) [%d]\n", addr,
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2.6.26-rc4] Fix nesting error checking in arch/x86/mm/ioremap.c
2008-05-27 5:49 [PATCH 2.6.26-rc4] Fix nesting error checking in arch/x86/mm/ioremap.c Mika Kukkonen
@ 2008-05-27 8:00 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-05-27 8:00 UTC (permalink / raw)
To: mikukkon; +Cc: linux-kernel, torvalds, arjan, Thomas Gleixner, H. Peter Anvin
* Mika Kukkonen <mikukkon@srv1-m700-lanp.koti> wrote:
> unsigned int nesting;
>
> - nesting = --early_ioremap_nested;
> - WARN_ON(nesting < 0);
> + if (early_ioremap_nested)
> + nesting = --early_ioremap_nested;
> + else {
> + nesting = 0;
> + WARN_ON(1);
> + }
the better fix would be to turn 'nesting' into an int, hm?
Also, instead of forcing nesting to 0, it is better to just return - as
we cannot do any sane unmap here anymore. (we are unbalanced)
I.e. something like the fix below?
Ingo
------------------------------>
Subject: ioremap: nesting fix
From: Ingo Molnar <mingo@elte.hu>
Date: Tue May 27 09:56:49 CEST 2008
Mika Kukkonen noticed that the nesting check in early_iounmap() is not
actually done.
Reported-by: Mika Kukkonen <mikukkon@srv1-m700-lanp.koti>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/mm/ioremap.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Index: linux/arch/x86/mm/ioremap.c
===================================================================
--- linux.orig/arch/x86/mm/ioremap.c
+++ linux/arch/x86/mm/ioremap.c
@@ -602,10 +602,11 @@ void __init early_iounmap(void *addr, un
unsigned long offset;
unsigned int nrpages;
enum fixed_addresses idx;
- unsigned int nesting;
+ int nesting;
nesting = --early_ioremap_nested;
- WARN_ON(nesting < 0);
+ if (WARN_ON(nesting < 0))
+ return;
if (early_ioremap_debug) {
printk(KERN_INFO "early_iounmap(%p, %08lx) [%d]\n", addr,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-27 8:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-27 5:49 [PATCH 2.6.26-rc4] Fix nesting error checking in arch/x86/mm/ioremap.c Mika Kukkonen
2008-05-27 8:00 ` Ingo Molnar
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®