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: 73349 Delivered-To: patches@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1848714qga; Fri, 5 Aug 2016 03:04:04 -0700 (PDT) X-Received: by 10.28.232.149 with SMTP id f21mr2425956wmi.51.1470391444618; Fri, 05 Aug 2016 03:04:04 -0700 (PDT) Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id eo1si17745081wjb.236.2016.08.05.03.04.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Aug 2016 03:04:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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 Cc: patches@linaro.org, Fabien Chouteau , Mark Cave-Ayland , Artyom Tarasenko Subject: [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer 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 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(-) -- 2.7.4 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",