From patchwork Fri Nov 23 08:44:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151849 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1799795ljp; Fri, 23 Nov 2018 00:46:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/XpztX5hqrdzWIN5W/mbPgp8Njnq1isZ+GzxIUNGfRrib2Rf4skbeJkfyoFBMya4hA5n3Iv X-Received: by 2002:a05:660c:648:: with SMTP id y8mr2548895itk.48.1542962775968; Fri, 23 Nov 2018 00:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542962775; cv=none; d=google.com; s=arc-20160816; b=m+tYkeo9dZfWJQ5Orh8kFLAdnPWcuVZKRmJPV4qn9ReFHvF5+3sFyh9UrpGWEp5dIc b56YdX6s0xdIkYPwpMfL4BtyLSeTa+4OGGfgN+nnMyN3q6vjGwTawS4o8VEe2514dWFR 0eq8y7p74dDHPwZJiaVVsfpVpCoQSWhBNGyiJGP0x7/IMZNhxlv4He+fxpwj0t7BmJ12 Smn3duQH8dxXVc67SZEPmLMUnABhqpCxbllTPErYxWhcgQo6AYgyfcYmPA46JxUsbyQm 5ImxxLVxdqZ53tB0lcotkg7zACaEFov6eNIJwZrL6hiQjYkih5bYOF+9uoEc9d7xzYRQ YDJg== 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=a+oJUUGF6RGQapbSlaaGTXNWIWL5lBV740bYAy0ekAg=; b=OIpfVgLBHFcK550EgMsCFZxoEDXF6hw/VvrFJiUeEYNyA2L+8b5jLhyVkVCj2YLbQx bhLIKhB4eClp+E9HPMb1AnYxLlcZ6rQQe3xed2KcKHwUEEOV3UVZxh0D8BdRqnshRPDj 2NTHv3tebKMOWjLSgEW6xn04AnoRSqONP2/W1EgJpzyWwM/VeMh62N9gN5Zik0AwS53F KbyGaITbHKO1U+hdnBelhdeWdI0twAcKimuO0m4eorHpYoibd4aE/4nx76+7IIenkkPj KaQXJLfIxvdMfT/3dyycVFJwN5NUWihwtT6p5QpLQUPgVEx3xASMqxVCxnrY6IKPgi6B s2Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aI8d3g3d; 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 t1si4670232itf.51.2018.11.23.00.46.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 00:46:15 -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=aI8d3g3d; 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 7A0F821CB74A4; Fri, 23 Nov 2018 00:46:04 -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::442; helo=mail-wr1-x442.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 9592D21B02822 for ; Fri, 23 Nov 2018 00:44:15 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id 96so11520172wrb.2 for ; Fri, 23 Nov 2018 00:44:15 -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=Bb0R1IDjBPOBtw/Ni+Lped4iTM7acK5mOh+cMkl4yxk=; b=aI8d3g3d5KNgwEmiy2rB5c213VvW0feiH2G76snXI9wl9YXXUazmLrQjYPgCPBPnnu lWnupMzd7uYC19K3H1SXsdOb2P15aBLUL/UVg36GwpETXfwXnqoyKyZ6o4z03q4BJae4 l156y53w3cjuFAOXsXYiYb4MQu0a0+d+oKAXI= 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=Bb0R1IDjBPOBtw/Ni+Lped4iTM7acK5mOh+cMkl4yxk=; b=eraRl97vepgE1hjYHx8voJmz8hjkyc/Gt5YvYiy0YWyheu58oSTNzW2Lsh//Sk3+wU ZeJHY8F5SiKwez1+loWsAEMnCgve6Q97A8CitwH8yvMJOLDhWvXLD5RTzPu9gYHzxMcE 1KemUWuqWGeCqbuM/2qdklMqM62aqshDbh+/C7vEs2Jw+yriGstansR8X6dc3mCyrklu rd0Fefc6IyHECNtDk4pMEwho8YGGvkbqKFbVs5ws5erchjvkmeI+cP8jTAuJYL4UqowT C8990KuMsoXnMym0njlx91Sp7o+IniF4QUgUdkcQRd23DhoL0un9Fv6E2cmLtGnrxiz5 hOpA== X-Gm-Message-State: AA+aEWbHkVlwS14/k1yxWHwBraGmRgXgIGQOoGKmNpJWQayQqTXW4ew2 aeNxvoxwTLPzK+uEqlerzK14qfv5IKcluQ== X-Received: by 2002:adf:b201:: with SMTP id u1mr4778170wra.165.1542962653711; Fri, 23 Nov 2018 00:44:13 -0800 (PST) Received: from mba13.wifi.ns.nl (33.153.69.91.rev.sfr.net. [91.69.153.33]) by smtp.gmail.com with ESMTPSA id c8sm807377wrx.42.2018.11.23.00.44.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 00:44:12 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Nov 2018 09:44:06 +0100 Message-Id: <20181123084406.27192-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181123084406.27192-1-ard.biesheuvel@linaro.org> References: <20181123084406.27192-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 edk2-platforms 3/3] 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 and the function returns EFI_SUCCESS) Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/ARM/Library/BdsLib/BdsFilePath.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/Platform/ARM/Library/BdsLib/BdsFilePath.c b/Platform/ARM/Library/BdsLib/BdsFilePath.c index 62f796e5526d..ad66b2f82718 100644 --- a/Platform/ARM/Library/BdsLib/BdsFilePath.c +++ b/Platform/ARM/Library/BdsLib/BdsFilePath.c @@ -423,8 +423,8 @@ BdsConnectAndUpdateDevicePath ( } } - if (RemainingDevicePath) { - *RemainingDevicePath = Remaining; + if (!EFI_ERROR (Status) && RemainingDevicePath != NULL) { + *RemainingDevicePath = DuplicateDevicePath (Remaining); } return Status; @@ -1314,14 +1314,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