From nobody Fri May 3 19:22:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506524540346751.6323899411886; Wed, 27 Sep 2017 08:02:20 -0700 (PDT) Received: from localhost ([::1]:55173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDqj-0004PC-2j for importer@patchew.org; Wed, 27 Sep 2017 11:02:09 -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) 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) 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 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" I've recently seen this with valgrind while running the HMP tester: =3D=3D22373=3D=3D Conditional jump or move depends on uninitialised value(s) =3D=3D22373=3D=3D at 0x4A41FD: arm_disas_set_info (cpu.c:504) =3D=3D22373=3D=3D by 0x3867A7: monitor_disas (disas.c:390) =3D=3D22373=3D=3D by 0x38E80E: memory_dump (monitor.c:1339) =3D=3D22373=3D=3D by 0x38FA43: handle_hmp_command (monitor.c:3123) =3D=3D22373=3D=3D by 0x38FB9E: qmp_human_monitor_command (monitor.c:613) =3D=3D22373=3D=3D by 0x4E3124: qmp_marshal_human_monitor_command (qmp-ma= rshal.c:1736) =3D=3D22373=3D=3D by 0x769678: do_qmp_dispatch (qmp-dispatch.c:104) =3D=3D22373=3D=3D by 0x769678: qmp_dispatch (qmp-dispatch.c:131) =3D=3D22373=3D=3D by 0x38B734: handle_qmp_command (monitor.c:3853) =3D=3D22373=3D=3D by 0x76ED07: json_message_process_token (json-streamer= .c:105) =3D=3D22373=3D=3D by 0x78D40A: json_lexer_feed_char (json-lexer.c:323) =3D=3D22373=3D=3D by 0x78D4CD: json_lexer_feed (json-lexer.c:373) =3D=3D22373=3D=3D 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 executio= n") Signed-off-by: Thomas Huth Reviewed-by: Richard Henderson --- 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_ulon= g code, =20 s.cpu =3D cpu; s.info.read_memory_func =3D target_read_memory; - s.info.read_memory_inner_func =3D NULL; s.info.buffer_vma =3D code; s.info.buffer_length =3D size; s.info.print_address_func =3D 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 disassemb= le_info *); (INFO).buffer_vma =3D 0, \ (INFO).buffer_length =3D 0, \ (INFO).read_memory_func =3D buffer_read_memory, \ + (INFO).read_memory_inner_func =3D NULL, \ (INFO).memory_error_func =3D perror_memory, \ (INFO).print_address_func =3D generic_print_address, \ (INFO).print_insn =3D NULL, \ --=20 1.8.3.1