From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 A6DF12118FF2F for ; Thu, 22 Nov 2018 09:26:54 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id v13so6512178wrw.5 for ; Thu, 22 Nov 2018 09:26:54 -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=x/OeQm0qk5VJTtBuZHjMBRF5O0T49HOmBrvWMsS/reA=; b=c0NBw9lxBzeze0LtmBYZpLPfzEZQgOCrzJMyHiSazwl+L4ErWgLVOUxdBktag/wvgY Y7/mQwy6XFjHV9kNjiMdcK2nxHjPSWFeDUvkSm5KvqmaFgyAsu5y7i6j8YA8eFPGsTlM ePSo915y//nW+KWgRXEQ3TfPcjAsj4xiKHSoE= 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=x/OeQm0qk5VJTtBuZHjMBRF5O0T49HOmBrvWMsS/reA=; b=kjVkwxWE/97pKR3r5Qn/bfY5hVtVA5eE6xw0FDDwBFjg2db7ik5rFyn9bciTvLFu8i sWTQacyqHtrEXke1qSQiF9RPuPu/8pq5bLUWyOHoAGVYWvr4yB/cB91zkYVJR/h8DRe6 RVwmjyhUCex256bSuuq47TInXKRdPm3fXpwloNgp7uDR65Gf4ukafBMj/Sgup60ve2Kq eeR9ldrg6X+QFy5VugA/TINS9x0PqV8I4gio1PzLJzBFxwLd9l9kZxs/7Jc0GKLd8YeG YVYmqAMX5YF6j84X6ncJtb8KgwjJr5H9dj03ErioYbWY4yKEdk8LLqyQVhDz/Mgq5XOR drJQ== X-Gm-Message-State: AA+aEWaefvVTQy7CLpYMhofDYIqX3IFui/sKwNIfpcgB6XVMPBHDDTS9 BgBHnKqmNdok1tHQ56VL6jUa3dv0TVPmcA== X-Google-Smtp-Source: AFSGD/UqBt8i8rVLHR4k+prxzNc6D58VQfSa6Na6EUgLhv0Pyo8/0XebyC8JawfDb/dyFkNXgvsFZQ== X-Received: by 2002:adf:9f10:: with SMTP id l16mr10820258wrf.206.1542907612909; Thu, 22 Nov 2018 09:26:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 09:26:52 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, thomas.abraham@arm.com, nariman.poushin@linaro.org, lersek@redhat.com, philmd@redhat.com, Ard Biesheuvel Date: Thu, 22 Nov 2018 18:26:44 +0100 Message-Id: <20181122172645.20819-4-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: [PATCH edk2-platforms 3/4] Platform/ARM/BdsLib: don't clobber BdsLoadImage() DevicePath IN param 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: , X-List-Received-Date: Thu, 22 Nov 2018 17:26:55 -0000 BdsLoadImage () is part of the BdsLib library API and is not documented as modifying its DevicePath argument, but does so nonetheless. So take a copy instead, and free it after use. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/ARM/Library/BdsLib/BdsFilePath.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Platform/ARM/Library/BdsLib/BdsFilePath.c b/Platform/ARM/Library/BdsLib/BdsFilePath.c index 67dafa4f3651..74fdbbee773d 100644 --- a/Platform/ARM/Library/BdsLib/BdsFilePath.c +++ b/Platform/ARM/Library/BdsLib/BdsFilePath.c @@ -1351,5 +1351,16 @@ BdsLoadImage ( OUT UINTN *FileSize ) { - return BdsLoadImageAndUpdateDevicePath (&DevicePath, Type, Image, FileSize); + EFI_DEVICE_PATH *Path; + EFI_STATUS Status; + + Path = DuplicateDevicePath (DevicePath); + if (Path == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = BdsLoadImageAndUpdateDevicePath (&Path, Type, Image, FileSize); + FreePool (Path); + + return Status; } -- 2.17.1