public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] arch/i386/kernel/io_apic.c: handle a negative return value
@ 2006-11-12 17:48 Adrian Bunk
  2006-11-13  8:08 ` Ingo Molnar
  2006-11-14  0:42 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Adrian Bunk @ 2006-11-12 17:48 UTC (permalink / raw)
  To: mingo; +Cc: linux-kernel

The Coverity checker noted that bad things might happen if 
find_isa_irq_apic() returned -1.

Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6/arch/i386/kernel/io_apic.c.old	2006-11-12 18:41:24.000000000 +0100
+++ linux-2.6/arch/i386/kernel/io_apic.c	2006-11-12 18:42:00.000000000 +0100
@@ -2160,7 +2160,8 @@ static inline void unlock_ExtINT_logic(v
 
 	pin  = find_isa_irq_pin(8, mp_INT);
 	apic = find_isa_irq_apic(8, mp_INT);
-	if (pin == -1)
+
+	if ((pin == -1) || (apic == -1))
 		return;
 
 	entry0 = ioapic_read_entry(apic, pin);


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

* Re: [2.6 patch] arch/i386/kernel/io_apic.c: handle a negative return value
  2006-11-12 17:48 [2.6 patch] arch/i386/kernel/io_apic.c: handle a negative return value Adrian Bunk
@ 2006-11-13  8:08 ` Ingo Molnar
  2006-11-14  0:42 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2006-11-13  8:08 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-kernel

On Sun, 2006-11-12 at 18:48 +0100, Adrian Bunk wrote:
> The Coverity checker noted that bad things might happen if 
> find_isa_irq_apic() returned -1.
> 
> Signed-off-by: Adrian Bunk <bunk@stusta.de>

hm, it seems the checker did not notice the following:
find_isa_irq_apic() can return -1 /only/ if find_isa_irq_pin() returns
-1 too. So this is not a bug - it's rather a bit unclean code (and
adding a check for -1 apic does not make the code cleaner).

	Ingo 


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

* Re: [2.6 patch] arch/i386/kernel/io_apic.c: handle a negative return value
  2006-11-12 17:48 [2.6 patch] arch/i386/kernel/io_apic.c: handle a negative return value Adrian Bunk
  2006-11-13  8:08 ` Ingo Molnar
@ 2006-11-14  0:42 ` Andrew Morton
  2006-11-14  6:46   ` Ingo Molnar
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2006-11-14  0:42 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: mingo, linux-kernel

On Sun, 12 Nov 2006 18:48:26 +0100
Adrian Bunk <bunk@stusta.de> wrote:

> The Coverity checker noted that bad things might happen if 
> find_isa_irq_apic() returned -1.
> 
> Signed-off-by: Adrian Bunk <bunk@stusta.de>
> 
> --- linux-2.6/arch/i386/kernel/io_apic.c.old	2006-11-12 18:41:24.000000000 +0100
> +++ linux-2.6/arch/i386/kernel/io_apic.c	2006-11-12 18:42:00.000000000 +0100
> @@ -2160,7 +2160,8 @@ static inline void unlock_ExtINT_logic(v
>  
>  	pin  = find_isa_irq_pin(8, mp_INT);
>  	apic = find_isa_irq_apic(8, mp_INT);
> -	if (pin == -1)
> +
> +	if ((pin == -1) || (apic == -1))
>  		return;
>  

I dunno about this.  For some reason I don't trust the apic code much.  At
present if find_isa_irq_apic() fails we at least have a chance of
blundering into a nnice oops or something.  By adding correct
error-checking we increase the chance of things just silently not working.

So let's see what this does...




From: Adrian Bunk <bunk@stusta.de>

The Coverity checker noted that bad things might happen if
find_isa_irq_apic() returned -1.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 arch/i386/kernel/io_apic.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)

diff -puN arch/i386/kernel/io_apic.c~arch-i386-kernel-io_apicc-handle-a-negative-return-value arch/i386/kernel/io_apic.c
--- a/arch/i386/kernel/io_apic.c~arch-i386-kernel-io_apicc-handle-a-negative-return-value
+++ a/arch/i386/kernel/io_apic.c
@@ -2166,9 +2166,17 @@ static inline void unlock_ExtINT_logic(v
 	unsigned char save_control, save_freq_select;
 
 	pin  = find_isa_irq_pin(8, mp_INT);
+	if (pin == -1) {
+		printk(KERN_ERR "unlock_ExtINT_logic: find_isa_irq_pin()
+				"failed\n");
+		return;
+	}
 	apic = find_isa_irq_apic(8, mp_INT);
-	if (pin == -1)
+	if (apic == -1) {
+		printk(KERN_ERR "unlock_ExtINT_logic: find_isa_irq_apic()
+				"failed\n");
 		return;
+	}
 
 	entry0 = ioapic_read_entry(apic, pin);
 	clear_IO_APIC_pin(apic, pin);
_




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

* Re: [2.6 patch] arch/i386/kernel/io_apic.c: handle a negative return value
  2006-11-14  0:42 ` Andrew Morton
@ 2006-11-14  6:46   ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2006-11-14  6:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Adrian Bunk, linux-kernel

On Mon, 2006-11-13 at 16:42 -0800, Andrew Morton wrote:
>         pin  = find_isa_irq_pin(8, mp_INT);
> +       if (pin == -1) {
> +               printk(KERN_ERR "unlock_ExtINT_logic:
> find_isa_irq_pin()
> +                               "failed\n");
> +               return;
> +       }
>         apic = find_isa_irq_apic(8, mp_INT);
> -       if (pin == -1)
> +       if (apic == -1) {
> +               printk(KERN_ERR "unlock_ExtINT_logic:
> find_isa_irq_apic()
> +                               "failed\n");
>                 return;
> +       } 

as i mentioned it in my mail yesterday, if find_isa_irq_apic() returns
-1 then find_isa_irq_pin() has to return -1 too. But this is obscure and
needs to be documented at least - and your patch is good for
documentation purposes too :-)

Acked-by: Ingo Molnar <mingo@redhat.com>

	Ingo


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

end of thread, other threads:[~2006-11-14  6:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-12 17:48 [2.6 patch] arch/i386/kernel/io_apic.c: handle a negative return value Adrian Bunk
2006-11-13  8:08 ` Ingo Molnar
2006-11-14  0:42 ` Andrew Morton
2006-11-14  6:46   ` Ingo Molnar

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