From patchwork Wed Sep 27 14:58:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 819209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2Ld11HMqz9tXs for ; Thu, 28 Sep 2017 01:01:41 +1000 (AEST) Received: from localhost ([::1]:55172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDqF-00041N-C4 for incoming@patchwork.ozlabs.org; Wed, 27 Sep 2017 11:01:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDnV-0001r2-Ee for qemu-devel@nongnu.org; Wed, 27 Sep 2017 10:58:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxDnR-0002EQ-Mk for qemu-devel@nongnu.org; Wed, 27 Sep 2017 10:58:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51934) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxDnJ-0002BP-FR; Wed, 27 Sep 2017 10:58:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 573C88765D; Wed, 27 Sep 2017 14:58:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 573C88765D Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=thuth@redhat.com Received: from thh440s.redhat.com (ovpn-117-38.ams2.redhat.com [10.36.117.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDF88C2282; Wed, 27 Sep 2017 14:58:34 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Wed, 27 Sep 2017 16:58:33 +0200 Message-Id: <1506524313-20037-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 27 Sep 2017 14:58:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] disas: Always initialize read_memory_inner_func properly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julian Brown , Peter Maydell , qemu-arm@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" I've recently seen this with valgrind while running the HMP tester: ==22373== Conditional jump or move depends on uninitialised value(s) ==22373== at 0x4A41FD: arm_disas_set_info (cpu.c:504) ==22373== by 0x3867A7: monitor_disas (disas.c:390) ==22373== by 0x38E80E: memory_dump (monitor.c:1339) ==22373== by 0x38FA43: handle_hmp_command (monitor.c:3123) ==22373== by 0x38FB9E: qmp_human_monitor_command (monitor.c:613) ==22373== by 0x4E3124: qmp_marshal_human_monitor_command (qmp-marshal.c:1736) ==22373== by 0x769678: do_qmp_dispatch (qmp-dispatch.c:104) ==22373== by 0x769678: qmp_dispatch (qmp-dispatch.c:131) ==22373== by 0x38B734: handle_qmp_command (monitor.c:3853) ==22373== by 0x76ED07: json_message_process_token (json-streamer.c:105) ==22373== by 0x78D40A: json_lexer_feed_char (json-lexer.c:323) ==22373== by 0x78D4CD: json_lexer_feed (json-lexer.c:373) ==22373== by 0x38A08D: monitor_qmp_read (monitor.c:3895) And indeed, in monitor_disas, the read_memory_inner_func variable was not initialized, but arm_disas_set_info() expects this to be NULL or a valid pointer. Let's properly set this to NULL in the INIT_DISASSEMBLE_INFO to fix it in all functions that use the disassemble_info struct. Fixes: f7478a92dd9ee2276bfaa5b7317140d3f9d6a53b ("Fix Thumb-1 BE32 execution") Signed-off-by: Thomas Huth --- disas.c | 1 - include/disas/bfd.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/disas.c b/disas.c index d6a1eb9..54eea3f 100644 --- a/disas.c +++ b/disas.c @@ -190,7 +190,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, s.cpu = cpu; s.info.read_memory_func = target_read_memory; - s.info.read_memory_inner_func = NULL; s.info.buffer_vma = code; s.info.buffer_length = size; s.info.print_address_func = generic_print_address; diff --git a/include/disas/bfd.h b/include/disas/bfd.h index b01e002..d99da68 100644 --- a/include/disas/bfd.h +++ b/include/disas/bfd.h @@ -479,6 +479,7 @@ int generic_symbol_at_address(bfd_vma, struct disassemble_info *); (INFO).buffer_vma = 0, \ (INFO).buffer_length = 0, \ (INFO).read_memory_func = buffer_read_memory, \ + (INFO).read_memory_inner_func = NULL, \ (INFO).memory_error_func = perror_memory, \ (INFO).print_address_func = generic_print_address, \ (INFO).print_insn = NULL, \