From nobody Sat Feb 7 05:52:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1586234260; cv=none; d=zohomail.com; s=zohoarc; b=YoYLSEceRtsxVvRvJqsUF8SaURWfgCNCu3eaiFl9vmTJbpbYaZ6+scFZEMJrQW+ByHQec96hhpVREoKxx4vyqctqddZt4C+wxYjACOZopTlIEzo4UVoHxQDOcOSffLMfzSUR3gnNJ65jctLMKd7EDfIOvd+B/WHsypohkdrUS6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586234260; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HS3oFe4drWUjptxn2eG6bAMW+766RKu9wS0DwWeWdNE=; b=e8IZt5VJy0u66ZFDmIoq+y8BWKV9AJMeaS/W1WRvz3XMuZ+vu7OOSh7Dmz8mjaFxUtuD3iI08z/O6x+0+jbFjkN7tY8zKPGhm0nt2XYUuPmA/7oPYyhnrelVZyKlrVXa59FsmHiizCI7fhsAIRSP11iIwhKdJwKy0YpJO6g2kRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586234260050217.13988151978128; Mon, 6 Apr 2020 21:37:40 -0700 (PDT) Received: from localhost ([::1]:40994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLfzV-0001D7-HL for importer@patchew.org; Tue, 07 Apr 2020 00:37:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52272) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLfyK-0007xs-DF for qemu-devel@nongnu.org; Tue, 07 Apr 2020 00:36:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLfyJ-0004Aq-EG for qemu-devel@nongnu.org; Tue, 07 Apr 2020 00:36:24 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:48261) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLfyH-00045Q-QU; Tue, 07 Apr 2020 00:36:23 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48xF3K0Dqfz9sR4; Tue, 7 Apr 2020 14:36:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1586234173; bh=hHIGRjoFYCwEG4FYc0AkcpQkI4ODTreh/O1iHm8vwyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cmFL7lc1mD/Ev/HAAS8Te0JtMPNiB4gyeL05NMdvX8DMYMmLXQwtfFmpCKXqaUXJ7 Q7rS24JdyHnETg3XLJxYIm8bEotBhCU+CDo8eiPnDPegp1QTkQvrrJzoVXDoSzh/zR SvS/yuqOPfBCD7rWs0F+4zfcxdmxF6tYFqQPAH+A= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 01/10] hw/ppc/e500.c: Handle qemu_find_file() failure Date: Tue, 7 Apr 2020 14:35:57 +1000 Message-Id: <20200407043606.291546-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200407043606.291546-1-david@gibson.dropbear.id.au> References: <20200407043606.291546-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Maydell If qemu_find_file() doesn't find the BIOS it returns NULL; we were passing that unchecked through to load_elf(), which assumes a non-NULL pointer and may misbehave. In practice it fails with a weird message: $ qemu-system-ppc -M ppce500 -display none -kernel nonesuch Bad address qemu-system-ppc: could not load firmware '(null)' Handle the failure case better: $ qemu-system-ppc -M ppce500 -display none -kernel nonesuch qemu-system-ppc: could not find firmware/kernel file 'nonesuch' Spotted by Coverity (CID 1238954). Signed-off-by: Peter Maydell Message-Id: <20200324121216.23899-1-peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Gibson --- hw/ppc/e500.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 854cd3ac46..0d1f41197c 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -1047,6 +1047,10 @@ void ppce500_init(MachineState *machine) } =20 filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, payload_name); + if (!filename) { + error_report("could not find firmware/kernel file '%s'", payload_n= ame); + exit(1); + } =20 payload_size =3D load_elf(filename, NULL, NULL, NULL, &bios_entry, &loadaddr, NULL, NULL, --=20 2.25.2