From patchwork Thu Nov 22 17:26:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151807 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1018643ljp; Thu, 22 Nov 2018 09:26:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/WaSqhtLD92DvT1P1DV06zyJ0+bcW0LfbbQn/Ji9uDXqg2OJFEaW2CL2z2TI+pDg0h1ulsL X-Received: by 2002:a17:902:6907:: with SMTP id j7mr11696684plk.221.1542907617836; Thu, 22 Nov 2018 09:26:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542907617; cv=none; d=google.com; s=arc-20160816; b=1GC9t8NDFma2X/jHVpJe2q6MqE5/JLZFw7Cre9ZwG8336gluMwhfxDHYwWaj23KuDb xzNinSpD/RVHzg7yS8PzuuMc0S8mMswy/wH4ZUYoh9KL02a22vt+VVMytZbXd5eNVNYD k4UW85hobj1X7TtGB1NGMzzT3G3wGpIC03SxnkKibvPqnQeY3n9aNrY4K7M2Nilshipx Gepr6nznoKpUenstkpZ0dMpAtBarUcjGLxN/oC5T2mSkNxf3A1PgGWtaC181TiWKzUoj XEhbk4AAGI9QB+PxLXkkJM/OObkVfGc6NzEI39vJ0CCECm035CRgPE2ja7+aUJOzmeZT 4XJg== 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=BPdc6Zdle8Lbd1Cce2h7EaP+FS4AVmKgvYDvk7iwnt8=; b=yQyiuGaOC8kBNdCuYuiVaRPiXuA2619CmpeRrJrYNR9V2jwHg2hpTkDej5EXazmZpr tnwGN2QybGRzZ63gfPPuqecbVaz4734BhXMtD/uce9TkpIRKk68MollCH+0VvZO9wQ8Q f1tGEFRyl5fOQrRPvnVSndWfm00VvcehCFQ0mq3vKi3i4lOqSzpuMW+3mqcMU9UoDolP AUBLXvVjR77bawAIw5Tn9aYoIElCHa8eoMj8rh5BcxVp8x3CHBMy2+mwywFFgEIPqWAS RMilyabUfa2VA814X4aZP+ZmzuqaHfME+vN26E1kB8y12HaC2mP80C+pCqXBvVuBH6qR GRRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c0NBw9lx; 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 a3-v6si50629594plp.323.2018.11.22.09.26.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 09:26:57 -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=c0NBw9lx; 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 568BA2119486F; 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::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-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 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: [edk2] [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: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 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 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; }