From patchwork Thu Nov 22 17:26:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151810 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1018675ljp; Thu, 22 Nov 2018 09:27:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/XDT2y89lNBG+DaP5C8g8GRmMZ6OBDEwjlfHlE3zOrNopeXMDig9NRP2y74i6yusofAbdB/ X-Received: by 2002:a17:902:930b:: with SMTP id bc11mr12396409plb.17.1542907620332; Thu, 22 Nov 2018 09:27:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542907620; cv=none; d=google.com; s=arc-20160816; b=OF+62kqxnhTCoLmzGdiZ8EEH/DvBccNHsosI0T96hFKRTpoy4zxZw4iSoPHYKhLDki /jcLlTbUXPSXMJ/++VsLwMfarHWvRKr+t93Z9Cf36mveNM3rvGLdcDW93CPspdKaL1zw fcHs9CXflrj+lk3atKMk0Sy2K1/fTvxu1Z7owtJmU4gU651wTAV4qDV6PJQs+itT4bKZ e8Oo4dB1o61Yg6t4FyIakkXAT0wCbREorXXBrlQB9yusLemo/bhWRFROdUP710pkmolo RGlbE9OW1oaVyHq+M58Po3cKETiPKx1ODlwK/3mcCRcEodl/oAHF+KMGukluGWuhggnD qF4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=1Nm9NwxZZuPNE3Mok5VRuu15KNnfeQgtjosqQm5mPpY=; b=yc8tG0AVNtQNHghPR7fAPhFtvs1h6wgbw4GMPLPCLaNtbI4zrmTbzGuaf9uGIhbW/h UUc3ZOEgY5JJQontpdDORr3HVuwfUlbJOc/CStyhxREo3/1TsuHhSGgNCk8waXPCkQWw X6CdQlDWWj1ohu76ux6ebDNLWg7s/3rYOOUmDZTRzCS1CAeqK4xnRA/zJbjj/X1RTHzr hR8bHflt0V2TYNDMuAJtgXIMqceOi+MtoQ4hQ/0VaHJoV9M5pvF1Z/xMLurO0+8j1GCd AZfga+b88gRfpHyub2mT2BNBanfOtec++E+KNsxAuLyrwvYtRBrqxTRcekFC1VDcouNM gj6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fnO5Tl67; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 2si50916130pgz.395.2018.11.22.09.27.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 09:27:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fnO5Tl67; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8A5F42194D3AE; Thu, 22 Nov 2018 09:26:57 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E205221194866 for ; Thu, 22 Nov 2018 09:26:55 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id s11so9877146wmh.1 for ; Thu, 22 Nov 2018 09:26:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kkoOGjShLB/eVAtaF07dmtGTtZx7IE48RHEToeHH248=; b=fnO5Tl67PWmvBCOO6l59d9dKhthixoSBrqTcsmjyyttCo+Qyvik7B/WKMMLbSNLeAI IDELPVRlLlCbe2MdjJcz4NFc+hy/rhckUTS8dlaqoAsYaYJEwO9VGoaRWwYXPatSsPBu 3M+wOV5whZQYZJEVyDwwt3gpku+zekg97RS1Q= 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:in-reply-to :references; bh=kkoOGjShLB/eVAtaF07dmtGTtZx7IE48RHEToeHH248=; b=ff98a4D9i3dNJvktj3XrairIDfbK7LCL+9Xmi7Lav/hHj0tVelOPVjWHCOj3KIv2zD Pkk9zeT9Xn7lz2WLpeJCPLL5VVFmSMoyxvOwKBI+d4alVF8IxOXnvKhRy4D+Pvvf7THL R+X5fs3lRA3c6ig9EY87mwMSf+FikXG/pc+eYGfZ9O091/6asG1pHUgijovxB+jQTfr3 YVXwx65nU27rsHOnxV/RckLlwLGsZg5ttxusIJwM0L08v0Fvuk7G6bEUQ997/Ym+0Sws IS4X5p4r9dBKSg7XmiNdV0ZO8GBm3yhaLGzNESZgeBKSyyIOqtzk51ruQn5kmhAtMfDq MFww== X-Gm-Message-State: AGRZ1gI5qtsdOmRrGlEhZW8JJYHxELhXhvtbkSjPdOwgKlVyS6c12E2a lMmtIQJG2cznzx7DOAuQjmwKB1TV3zIi8g== X-Received: by 2002:a1c:248b:: with SMTP id k133-v6mr10157397wmk.148.1542907614110; Thu, 22 Nov 2018 09:26:54 -0800 (PST) Received: from mba13.wifi.ns.nl ([2a01:cb1d:112:6f00:6422:2edf:11bf:f2b]) by smtp.gmail.com with ESMTPSA id v1sm8874985wrw.90.2018.11.22.09.26.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 09:26:53 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 22 Nov 2018 18:26:45 +0100 Message-Id: <20181122172645.20819-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181122172645.20819-1-ard.biesheuvel@linaro.org> References: <20181122172645.20819-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms 4/4] Platform/ARM/BdsLib: maintain alignment for DevicePaths X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" DevicePath node types may have any size, and so it is up to the code that manipulates them to ensure that dereferencing them only occurs when the pointer is aligned explicitly. Since BdsConnectAndUpdateDevicePath() has only two callers, one of which itself, we can simply duplicate the device path (similar to how DxeCore's CoreConnectController () does it), and free the pool allocation again on the way out. (Note that the allocation only occurs when the non-recursive path is taken) Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/ARM/Library/BdsLib/BdsFilePath.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/ARM/Library/BdsLib/BdsFilePath.c b/Platform/ARM/Library/BdsLib/BdsFilePath.c index 74fdbbee773d..543ac8f83086 100644 --- a/Platform/ARM/Library/BdsLib/BdsFilePath.c +++ b/Platform/ARM/Library/BdsLib/BdsFilePath.c @@ -421,7 +421,7 @@ BdsConnectAndUpdateDevicePath ( } if (RemainingDevicePath) { - *RemainingDevicePath = Remaining; + *RemainingDevicePath = DuplicateDevicePath (Remaining); } return Status; @@ -1333,14 +1333,18 @@ BdsLoadImageAndUpdateDevicePath ( } FileLoader = FileLoaders; + Status = EFI_UNSUPPORTED; while (FileLoader->Support != NULL) { if (FileLoader->Support (*DevicePath, Handle, RemainingDevicePath)) { - return FileLoader->LoadImage (DevicePath, Handle, RemainingDevicePath, Type, Image, FileSize); + Status = FileLoader->LoadImage (DevicePath, Handle, RemainingDevicePath, + Type, Image, FileSize); + break; } FileLoader++; } - return EFI_UNSUPPORTED; + FreePool (RemainingDevicePath); + return Status; } EFI_STATUS