From patchwork Fri Aug 5 10:03:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9265167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5FCA36048B for ; Fri, 5 Aug 2016 10:22:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E48428409 for ; Fri, 5 Aug 2016 10:22:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D79D28415; Fri, 5 Aug 2016 10:22:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE06328409 for ; Fri, 5 Aug 2016 10:22:50 +0000 (UTC) Received: from localhost ([::1]:44215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVcHB-0002JG-Q4 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 Aug 2016 06:22:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVbz4-0000OD-Qr for qemu-devel@nongnu.org; Fri, 05 Aug 2016 06:04:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVbz2-0003eU-Td for qemu-devel@nongnu.org; Fri, 05 Aug 2016 06:04:05 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58553) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVbz2-0003eQ-N4 for qemu-devel@nongnu.org; Fri, 05 Aug 2016 06:04:04 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bVbz1-0007ni-5I; Fri, 05 Aug 2016 11:04:03 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 5 Aug 2016 11:03:59 +0100 Message-Id: <1470391439-28427-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer 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: Mark Cave-Ayland , Artyom Tarasenko , Fabien Chouteau , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP get_image_size() doesn't handle being passed a NULL pointer, so avoid doing that. Spotted by the clang ub sanitizer (which notices the attempt to pass NULL to open()). Signed-off-by: Peter Maydell --- hw/sparc/leon3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index dbae41f..6e16478 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -171,7 +171,11 @@ static void leon3_generic_hw_init(MachineState *machine) } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); - bios_size = get_image_size(filename); + if (filename) { + bios_size = get_image_size(filename); + } else { + bios_size = -1; + } if (bios_size > prom_size) { fprintf(stderr, "qemu: could not load prom '%s': file too big\n",