From patchwork Wed Jul 25 05:30:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 142844 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp388252ljj; Tue, 24 Jul 2018 22:33:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfMEaQfvYIrkMDDvtwKUKq5mcFZgG1puXjpVv9oycSYUHNBLTpljMvdRnlMhkz/mMyOUbcx X-Received: by 2002:a37:ab17:: with SMTP id u23-v6mr18134617qke.279.1532496795096; Tue, 24 Jul 2018 22:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532496795; cv=none; d=google.com; s=arc-20160816; b=T0lFiPPdCe+2SCDRpIqhq8jVz8vC24MjRgxDE3LO1MGSYIQnEEWEuBWv7ezobDjVmu ge4ixmqz0m3T01oLWHy8Xm4D41VayFoMadejTkmxb2ZgXPwN915PMqS/1TUVRnB4GCjW fSavi5gJtQHvrypejyswYQyyBMZWAy/10WDj39or1EhB3gIA5Hw4lO3GiGEd1cuXmlAo MPv0W0x7J7cptIpsW2SE4ULvE0yycfb8tpySeTZiqS1wRi4ZALpj7sVb0DrlOmddEtr7 u5UIhyeVWbGh00tOk8kYB8QlPyOnqKqixoMkX6Q0EYZ7/UOIYNhyCGv4p0K63gC7VEbm etmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=NNN8mjnF2Vz3g5GOst/CbeIh72InaXfGbwD4IxSBb8c=; b=fU0Nl5C5nqizRgXsBWcSq+54dgXbiSclZKihcdVR497FFuC9w5Md4M1cv6wM4uEPQT 4aMe5URU1UIhdpxCpzb2E3XDSA9DAmynKAG1Qw7uUYCWsxgk6fCFoYwAokk8R3WPQgc9 CsQJP5sksFV5r+PKU3FjHO49u2czByP6ZXA9PqCtGnhAVKtTn92yd5cjkhqGcqSnF7P6 gyueKpeHc3qCWZhfkB+EvKUvbj5d09CuRsvGZFalEGWblY9G0Q8Od9J4vrdjvom1QYp5 JdyhllLt7mjvxz+c3ZBR0M/tMDYgVde3EwozoQpipmJ4NmR2OKfuwPoR5u9ca2To2nTg IOjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NnjQ4Evw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p9-v6si6114664qtf.102.2018.07.24.22.33.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 24 Jul 2018 22:33:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NnjQ4Evw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiCQE-00046T-Jo for patch@linaro.org; Wed, 25 Jul 2018 01:33:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiCOC-0003RH-Dj for qemu-devel@nongnu.org; Wed, 25 Jul 2018 01:31:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fiCO9-0007vf-Ek for qemu-devel@nongnu.org; Wed, 25 Jul 2018 01:31:08 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:43099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fiCO9-0007vS-1G for qemu-devel@nongnu.org; Wed, 25 Jul 2018 01:31:05 -0400 Received: by mail-qk0-x242.google.com with SMTP id z74-v6so4160708qkb.10 for ; Tue, 24 Jul 2018 22:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=NNN8mjnF2Vz3g5GOst/CbeIh72InaXfGbwD4IxSBb8c=; b=NnjQ4Evww3G4v0Cmoaas5Yuir56afZ9ackVe8ydvdzTH3BeXxR7sSPTYvwRLKy77AP nW+PnFSulOhna0E3FLK92xoRGwfmKpXSqR7Qr6+mIi7YUP1NXf2GXTD2XRnkuU/bPU1x pwh0sBbbUP1NVPTh630rUgupEwAGniVS/XMmQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NNN8mjnF2Vz3g5GOst/CbeIh72InaXfGbwD4IxSBb8c=; b=KPM88t6/E4jzduskMyIR/7isbmccRzgboOQbSKnV0+y8egEQN7UVK/FKX1z+wBB+Rb CFuAmjdZ/DMDMlBHjcPTO7o+zHVPZfFsx4HJSoZbVmi/i/dcqDMVblxXD2ilBQYaHdkk WELGJLS3B3ti9zqh3JopmY/s9+8Bb2psQvx14Lfoiqfbus+gB/jHPyU6yoRSa0kHEzjc PllLs24CyL1AAenJeAtHp5/uQMUgwUB2Mt3B+dYPZp4fnJIEBOlglQ3PfFEe3KCXvYpu 1ULfkBVkT+kXGeRnY5xuwwOChKv9Ta1selgGFu7PsDZuREZNJvoAd2KtaAT6YN5SJzKS t5fA== X-Gm-Message-State: AOUpUlF8fdJYTjfGqeCGQ+LSrRx57WcmrSWPDovZKwsKaGcm6TeYEwxb Vm7jGsNmlmfjUNTCsYV/rdUpag== X-Received: by 2002:a37:5142:: with SMTP id f63-v6mr18186304qkb.369.1532496664198; Tue, 24 Jul 2018 22:31:04 -0700 (PDT) Received: from localhost.localdomain ([104.237.86.219]) by smtp.gmail.com with ESMTPSA id v129-v6sm8621380qkd.86.2018.07.24.22.31.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jul 2018 22:31:03 -0700 (PDT) From: Hongbo Zhang To: peter.maydell@linaro.org, alex.bennee@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Wed, 25 Jul 2018 13:30:51 +0800 Message-Id: <1532496652-26364-1-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH v2 1/2] hw/arm: check fw_cfg return value before using it 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: Hongbo Zhang , radoslaw.biernacki@linaro.org, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The fw_cfg value returned from fw_cfg_find() may be NULL, so check it before using. Signed-off-by: Hongbo Zhang --- hw/arm/boot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/hw/arm/boot.c b/hw/arm/boot.c index e09201c..43b217f 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -930,6 +930,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) hwaddr entry; static const ARMInsnFixup *primary_loader; AddressSpace *as = arm_boot_address_space(cpu, info); + FWCfgState *fw_cfg; /* CPU objects (unlike devices) are not automatically reset on system * reset, so we must always register a handler to do so. If we're @@ -960,11 +961,10 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) info->dtb_start = info->loader_start; } - if (info->kernel_filename) { - FWCfgState *fw_cfg; + fw_cfg = fw_cfg_find(); + if (info->kernel_filename && fw_cfg) { bool try_decompressing_kernel; - fw_cfg = fw_cfg_find(); try_decompressing_kernel = arm_feature(&cpu->env, ARM_FEATURE_AARCH64);