Received: from eggs.gnu.org ([2001:4830:134:3::10]:50582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZi6S-0000jL-6R for qemu-devel@nongnu.org; Mon, 24 Jul 2017 14:29:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZi6Q-0005Mz-0V for qemu-devel@nongnu.org; Mon, 24 Jul 2017 14:29:12 -0400 Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 24 Jul 2017 15:27:37 -0300 Message-Id: <20170724182751.18261-22-f4bug@amsat.org> In-Reply-To: <20170724182751.18261-1-f4bug@amsat.org> References: <20170724182751.18261-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH for 2.10 21/35] arm/sysbus-fdt: fix null pointer dereference List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-arm@nongnu.org Use error_report() + exit() instead of error_setg(&error_fatal). hw/arm/sysbus-fdt.c:322:9: warning: Array access (from variable 'node_path') results in a null pointer dereference if (node_path[1]) { ^~~~~~~~~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé --- hw/arm/sysbus-fdt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c index d68e3dcdbd..ad0cc49b19 100644 --- a/hw/arm/sysbus-fdt.c +++ b/hw/arm/sysbus-fdt.c @@ -315,15 +315,14 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev, void *opaque) node_path = qemu_fdt_node_path(host_fdt, dt_name, vdev->compat, &error_fatal); if (!node_path || !node_path[0]) { - error_setg(&error_fatal, "%s unable to retrieve node path for %s/%s", + error_report("%s unable to retrieve node path for %s/%s", __func__, dt_name, vdev->compat); - } - - if (node_path[1]) { - error_setg(&error_fatal, "%s more than one node matching %s/%s!", + exit(1); + } else if (node_path[1]) { + error_report("%s more than one node matching %s/%s!", __func__, dt_name, vdev->compat); + exit(1); } - g_free(dt_name); if (vbasedev->num_regions != 5) { -- 2.13.3