From patchwork Sun Oct 8 04:57:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 822975 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y8rtv2hsZz9t3t for ; Sun, 8 Oct 2017 16:06:15 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2504FC21EA5; Sun, 8 Oct 2017 05:01:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A3840C21E45; Sun, 8 Oct 2017 04:59:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6BA29C21C39; Sun, 8 Oct 2017 04:59:53 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 4BD68C21C41 for ; Sun, 8 Oct 2017 04:59:53 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LzXTy-1dF5oj3v0c-014jLQ; Sun, 08 Oct 2017 06:59:52 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 8 Oct 2017 06:57:28 +0200 Message-Id: <20171008045735.8137-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171008045735.8137-1-xypron.glpk@gmx.de> References: <20171008045735.8137-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:+a2yd5ytDEfj0D9SGHkl+DFa1mvXVryOt9YlbhHOCA6gMJMQF5M HBlqE5rK4c3yI1KPGGSDaJo8pnz4rLmP0qJZa8EghKVocr2ZTdms0+TZrDMQU/NvLZi5Pm9 Y/LyEs2avQZwz3S4MtDy/jOGKc2nGE8EkkZstDvHURWtWd8qSEFexG93r+kacU1dLvj+bP1 +XvblLo0eeNqDVTCsYYSw== X-UI-Out-Filterresults: notjunk:1; V01:K0:XMXEuWVK0B4=:lEyHKaErIKRspDfz/to3vE iD//YOEq8B5/oy8qFGUTvv2xO7HQq72ryQp4m9DE5ibkIyoqfKRb/gw8yCioTPaufDJzWscQo YA1G2w1kbKk5mqSLSO9KaJbYH4Yl/tFOnXjk5D4H8mPSpvrz636xLcicTtsVpIKCD86c+LnyW GlKUWvjWfXvNjn+lqrTAgCCGAykxZ9jcVvg6FhDaw9ODHrtJEjSyojAnLO5W0KBnUYdW4NMMQ HjK5f3RVzdkNTwIhtF5G+f9rDmYyWm68+MiQr5rrl4LU8Je1Wa9TtVsqsF66io14sS+YAja+M Eb4fodqgiIYCT1/ITpjysJctT4QN24MRNeSYBc/JRDiZjDgv+NyGbwOhtpz5N0d8D7OoBOyNZ AWJZfLWBSOJgwj8hX7UzNeZ5LPBVlS6//GjgUGgW/7hS/bxnN0K5GO38My05Z5bLTUMTdZa2D jlTRQcVXX0wAodha4LxqRXJFQ1zzfitGeN7+QDwPXLrHKJuYX5Or7l+fVfyu9VkojXWsxHNpU 0FoE5CQIwpGhcFmkTu8px//es6rSF6HbhBa5PRu4q8G7F5HsDbZ0xU2YCHcpki8S/XolZKKLv ft9dagJMGERd0KNXOdpddguj1UKGuoemRAqAS+JzIocvk4cMzxpXC6PZM+bjblmbNCw6Kp6Ph wVWYExKr+O6vVPbE2xYvNOHwcnNxNYjQUF5tEqFet+5e/YTwQS5Xci7LQyS0/xRS5kP3tA6qQ yiNXOsrthyMl4BpH+RxX8RifkrfeRCQxfOpp90Yv1dj10cyqRQiqlIlhhum1mv/cgZjVQGyBk Bb/8cOcoaHK04sDUIVLFPw4AkNruQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 04/11] efi_selftest: error handling in SNP test X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Avoid NULL pointer dereference after setup failed due to a missing network. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_selftest/efi_selftest_snp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c index 638be0147d..bdd6ce20da 100644 --- a/lib/efi_selftest/efi_selftest_snp.c +++ b/lib/efi_selftest/efi_selftest_snp.c @@ -198,7 +198,7 @@ static int setup(const efi_handle_t handle, */ ret = boottime->set_timer(timer, EFI_TIMER_PERIODIC, 10000000); if (ret != EFI_SUCCESS) { - efi_st_error("Failed to locate simple network protocol\n"); + efi_st_error("Failed to set timer\n"); return EFI_ST_FAILURE; } /* @@ -206,6 +206,7 @@ static int setup(const efi_handle_t handle, */ ret = boottime->locate_protocol(&efi_net_guid, NULL, (void **)&net); if (ret != EFI_SUCCESS) { + net = NULL; efi_st_error("Failed to locate simple network protocol\n"); return EFI_ST_FAILURE; } @@ -273,6 +274,12 @@ static int execute(void) */ unsigned int timeout = 10; + /* Setup may have failed */ + if (!net || !timer) { + efi_st_error("Cannot execute test after setup failure\n"); + return EFI_ST_FAILURE; + } + /* * Send DHCP discover message */