All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code
@ 2011-07-20 18:56 ` Stefan Weil
  0 siblings, 0 replies; 15+ messages in thread
From: Stefan Weil @ 2011-07-20 18:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

cppcheck reports this error:

qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
 s - otherwise it is redundant to check if s is null at line 385

If s were NULL, the printf() statement would crash.
Setting braces fixes this bug.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/sh_intc.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/sh_intc.c b/hw/sh_intc.c
index 0734da9..f73a4b0 100644
--- a/hw/sh_intc.c
+++ b/hw/sh_intc.c
@@ -382,13 +382,14 @@ void sh_intc_register_sources(struct intc_desc *desc,
 
 	sh_intc_register_source(desc, vect->enum_id, groups, nr_groups);
 	s = sh_intc_source(desc, vect->enum_id);
-	if (s)
-	    s->vect = vect->vect;
+        if (s) {
+            s->vect = vect->vect;
 
 #ifdef DEBUG_INTC_SOURCES
-	printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
-	       vect->enum_id, s->vect, s->enable_count, s->enable_max);
+            printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
+                   vect->enum_id, s->vect, s->enable_count, s->enable_max);
 #endif
+        }
     }
 
     if (groups) {
-- 
1.7.2.5



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

end of thread, other threads:[~2011-08-29 11:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-20 18:56 [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code Stefan Weil
2011-07-20 18:56 ` [Qemu-devel] " Stefan Weil
2011-07-20 18:56 ` [Qemu-trivial] [PATCH] tcg/mips: Fix regression caused by typo (copy + paste bug) Stefan Weil
2011-07-20 18:56   ` [Qemu-devel] " Stefan Weil
2011-07-20 21:04   ` [Qemu-trivial] " Blue Swirl
2011-07-25 10:22 ` [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code Stefan Hajnoczi
2011-07-25 10:22   ` [Qemu-devel] " Stefan Hajnoczi
2011-08-13  9:25 ` Stefan Weil
2011-08-13  9:25   ` [Qemu-devel] " Stefan Weil
2011-08-27 19:27   ` [Qemu-trivial] " Stefan Weil
2011-08-27 19:27     ` Stefan Weil
2011-08-28 11:13 ` [Qemu-trivial] " Andreas Färber
2011-08-28 11:13   ` Andreas Färber
2011-08-29 11:39 ` [Qemu-trivial] " Stefan Hajnoczi
2011-08-29 11:39   ` [Qemu-devel] " Stefan Hajnoczi

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.