From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzQkC-0002E8-Q9 for qemu-devel@nongnu.org; Fri, 02 Sep 2011 06:13:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QzQk8-0006Uo-Jp for qemu-devel@nongnu.org; Fri, 02 Sep 2011 06:13:04 -0400 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:58427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzQk8-0006Ud-Bh for qemu-devel@nongnu.org; Fri, 02 Sep 2011 06:13:00 -0400 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p82ACwE6023542 for ; Fri, 2 Sep 2011 10:12:58 GMT Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p82ACwRI2482376 for ; Fri, 2 Sep 2011 11:12:58 +0100 Received: from d06av06.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p82ACrxK032007 for ; Fri, 2 Sep 2011 04:12:54 -0600 From: Stefan Hajnoczi Date: Fri, 2 Sep 2011 11:12:50 +0100 Message-Id: <1314958372-23513-2-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1314958372-23513-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1314958372-23513-1-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 1/3] sh4: Fix potential crash in debug code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Stefan Hajnoczi From: 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 Reviewed-by: Andreas F=C3=A4rber Signed-off-by: Stefan Hajnoczi --- 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 ecb46e5..e07424f 100644 --- a/hw/sh_intc.c +++ b/hw/sh_intc.c @@ -382,13 +382,14 @@ void sh_intc_register_sources(struct intc_desc *des= c, =20 sh_intc_register_source(desc, vect->enum_id, groups, nr_groups); s =3D sh_intc_source(desc, vect->enum_id); - if (s) - s->vect =3D vect->vect; + if (s) { + s->vect =3D vect->vect; =20 #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_ma= x); #endif + } } =20 if (groups) { --=20 1.7.5.4