From patchwork Wed Apr 21 11:42:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri John Ledkov X-Patchwork-Id: 1468747 X-Patchwork-Delegate: rfried.dev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=surgut.co.uk header.i=@surgut.co.uk header.a=rsa-sha256 header.s=google header.b=XIgIFtAU; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQNLl0LPcz9sXM for ; Thu, 22 Apr 2021 00:32:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1D46819C3; Wed, 21 Apr 2021 16:32:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ubuntu.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=surgut.co.uk header.i=@surgut.co.uk header.b="XIgIFtAU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF12F80EBD; Wed, 21 Apr 2021 13:42:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7B4CF80F0B for ; Wed, 21 Apr 2021 13:42:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ubuntu.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dimitri.ledkov@surgut.co.uk Received: by mail-wr1-x430.google.com with SMTP id e7so32065777wrs.11 for ; Wed, 21 Apr 2021 04:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=surgut.co.uk; s=google; h=sender:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=O1sYRXAqZtB3DYt4MIPHZKl1Oq0ClkrnrOv3b3ocWXI=; b=XIgIFtAUmz+hQ8UcqgpDATm4gD5ArR9ZywLF6BQxp0c3Ow9xxhY2pa8VO6/IrOSv4X PAgeIvp0sEZjCokIdsNSrUEdBZ2XwEX/7QdowYzzCAzscg1tN/cVMPAWzB3+PFwk77EC osGOz3Sl79iKn1PgYIbHbhdyqQvx+5TCtRsU4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :mime-version:content-transfer-encoding; bh=O1sYRXAqZtB3DYt4MIPHZKl1Oq0ClkrnrOv3b3ocWXI=; b=PT4tNcpWFiHSH1818LVX8QDqcTVZiJWh0yUscJdni2IlCuOW1Gol9b3NY8KugSw9av i7MVt04/MAH7X3PKTtPuW4XfGhPKW2/jqns7CIqoUbFqT354LwwdgFL5uaeEyI/amNW0 NGDzOxW5ibYh1UYbQEtbIAaUIy5uMHoCilYIXLnJuP8B3UTjkrSRtXOKJ27nUFnHcuze 298heEIWBT+NZkQylzpYFdWalIVIiM8tzcBuwkxYLn4tOfbE1JQ/Pi6zRm7hNJvkAPvc eJKgVKOlTvzrQ20a/ynMcUVhhtOM1M02fvJmX03P+Z7wl0OAKfxABEDgkht0184ZrFYF dflw== X-Gm-Message-State: AOAM531+IvYw8LDjmHZW63Kkd8Si82WAs91OPE8Nynlf3obbiPzjF1fu Xmt2k8p7RJcvBsxWgZnekLiPjVbUWhzFjA== X-Google-Smtp-Source: ABdhPJzRE79+wmlYNo3qRWPv4XSDkY6HJE9y1wcOfGA1aIZfyGwuNzRHacXKXoCStg+F6MwU/F60lA== X-Received: by 2002:a5d:5407:: with SMTP id g7mr26942791wrv.149.1619005325690; Wed, 21 Apr 2021 04:42:05 -0700 (PDT) Received: from localhost ([2a01:4b00:85fd:d700:34bd:441f:358e:123f]) by smtp.gmail.com with ESMTPSA id w4sm2905467wrp.58.2021.04.21.04.42.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 04:42:05 -0700 (PDT) From: Dimitri John Ledkov To: u-boot@lists.denx.de Subject: [PATCH] cmd: pxe_utils: sysboot: fix crash if either board or soc are not set. Date: Wed, 21 Apr 2021 12:42:01 +0100 Message-Id: <20210421114201.57994-1-xnox@ubuntu.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 21 Apr 2021 16:32:37 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean If the environment does not have "soc" or "board" set, and fdtdir option is specified in extlinux.conf, the bootloader will crash whilst dereferencing a null pointer. Add a guard against null soc or board. Fixes a crash of qemu-riscv64_smode configuration, which does not have CONFIG_SYS_SOC defined. Signed-off-by: Dimitri John Ledkov Reviewed-by: Ramon Fried --- cmd/pxe_utils.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 71c5af4c25..9a30629e26 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -587,6 +587,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) f2 = "-"; f3 = env_get("board"); f4 = ".dtb"; + if (!f1) { + f1 = ""; + f2 = ""; + } + if (!f3) { + f2 = ""; + f3 = ""; + } } len = strlen(label->fdtdir);