From patchwork Mon Aug 12 20:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 818574 Delivered-To: patch@linaro.org Received: by 2002:adf:cd01:0:b0:367:895a:4699 with SMTP id w1csp3661wrm; Mon, 12 Aug 2024 13:58:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVkCtXjO+MUgW4e4oF9GXw/gH6qr5NyvbzBVykLlIX3f3eeiktKokK/FFVTmOjv3vA/LpWsiqVgDW4bAuZ0ME9G X-Google-Smtp-Source: AGHT+IHB8vk9LKrh4nqXMu9HPc983tK07WwK7BxV/RtLO73g2oble+1tYrm9RzajThKye/dGWYnD X-Received: by 2002:a05:6402:11d1:b0:5a1:b9c0:7758 with SMTP id 4fb4d7f45d1cf-5bd44c79ed0mr1018784a12.33.1723496297830; Mon, 12 Aug 2024 13:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723496297; cv=none; d=google.com; s=arc-20160816; b=QRb94goZj30udzrtIUzkE/8IoNMRDTMJlSElSmC0MhlbnUQCUcHQ+ZPmXN16oy/i/S oAWicucmxev9WTv9WdYLq33tZVyNolvwaIlHN1osBIzWECG6+X0TLmfo8B1CfQMQZnb3 2lwIxskZjZcUWIkUyKgVnEgyzl6wFZDSdnDXk7Va0WQ0+L+GtV1ylosv/BKu+67CyWzJ MO1TavvU2EiOmLjt85l9AefJHCASBxodsW7QKpAkn5+tQLwdhJ/kGGLAIxAhx8yCk0ea RnxASKntdkTSSyGkKDmlcuwZImcWHlDCZyCpeF6kOjIHtFEq0Udh6YzhJaYei4ULP1TG T/MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=/915ceIWv7aY9bGmDS6CEI/wALKVv480Vkfnxpg2xno=; fh=/JeJsCxW6lsweE3/hONtS51yWvA9r6mBB57kx6ISPko=; b=BY6mpTc2/nCxyUjgdUIG/7+3/WmYYK+Qt7IV+6jVWPxSE/LaYrAqr/W27shdoZWIDM qnuQGWicQfkh9CybVC59ll21vQLA569at5L7N6ZMMS03zmKZfkQkGnBAHiVPkbmGiNJX MJf6ZLBTspUISDPGRAEZDAr0hb4Jed/1jJNwkL7FqND1vrTSIpOqzekubhaaX0l9I0LB 0VkALQkG4L1HWge+23rozeXyKKzTMKgTurx+1Jp9qSlaTQaRwIGDsU7DcKFjJd9oQcl2 u3Tr6q38H+HdaGmpbxR7kZhQPVmt6OUxliMRB+Zqj1NxGfOpREuxw8rAA6yypDOUpcdx GmaQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wQusNVdq; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5bd1a5eff75si3299078a12.357.2024.08.12.13.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 13:58:17 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wQusNVdq; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4B2C687DB6; Mon, 12 Aug 2024 22:58:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wQusNVdq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1532787E9D; Mon, 12 Aug 2024 22:58:12 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 6B51186BF1 for ; Mon, 12 Aug 2024 22:58:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5bd13ea7604so3071075a12.1 for ; Mon, 12 Aug 2024 13:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723496289; x=1724101089; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/915ceIWv7aY9bGmDS6CEI/wALKVv480Vkfnxpg2xno=; b=wQusNVdqmksNhNTXbcHzFvVrs3a4qnJbaxNLOJgVWu2QxmsZGz43ngWndNMuVl4NKm yj8x1b234Q7pmhQFQr0MkzDmw0gT+WHzjWpzdj2Ni2FO93u2GPom5BPblf4i4DSTCJC4 BOrfGQsiNovblgI4IyUAU012qapRHuQjxMjCMX5DhQUp35bm3fyL3XGVo0DM2v9Ce0Tt dKDaI2zt33sNVQkf0UXCoavB/A6BpcY5sjZsflMIzEi+a70WgRLONqeBNCS8JtId9hT+ ii6s1vyjGLe2d9QqppCSaal2LvYZ8HyxF9KHD0l0SHz5BBDTxeWo3J4jRLdrG4/CaACf +Fgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723496289; x=1724101089; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/915ceIWv7aY9bGmDS6CEI/wALKVv480Vkfnxpg2xno=; b=RPLjiXB5aiAZW55clAKCE0wNsoJ73c1Nq5Mz5rsepJgBTXy+t2zRLKjomzJC7orkUS ACmWoz8CZSh6brhkx4c7q9iIdklaKbyW14HbXWawh1GTZNnCzoi3PyYMrKwllKWR3BBH QTbeMMWSTQGB4ysMuNxHVpSU6Unkr4/ksaW4533KOLgYERwwMg2Q1N5KA2YxWsdtW5vL J+zmnM1ABo5GzWmltUfnwSHs84FAVOs/syE1nuDTqqoUXF74eRDxvRCIzNHk33QjiicQ 96kpo77IKj2j7K95XaHlRDysXqKhFC+OD3f9qe55ub54HcEhpUhnC0he7rPNGzZKxEcJ xR3Q== X-Gm-Message-State: AOJu0YwaBZVUJ2ur+tR2U54lChoUzRU15wRsc4ujT4qXNhtlbHbJk6Yv M8pOaufNeoi/ISs0DnUsbwWczupYQIkWJmIje9cvVT0BDGVXNcoaMeEQ78E6W5c= X-Received: by 2002:a17:907:f15a:b0:a7a:a557:4548 with SMTP id a640c23a62f3a-a80ed1c1ee5mr112184566b.21.1723496288403; Mon, 12 Aug 2024 13:58:08 -0700 (PDT) Received: from localhost.localdomain (ppp046103060252.access.hol.gr. [46.103.60.252]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f3f475d8sm10183866b.38.2024.08.12.13.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 13:58:08 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: u-boot@lists.denx.de, Ilias Apalodimas Subject: [PATCH] efi_loader: fix memory freeing in efi_get_dp_from_boot() Date: Mon, 12 Aug 2024 23:57:59 +0300 Message-ID: <20240812205759.1732217-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean efi_get_var() allocates memory which must be freed after the variable is used. Since the device path is duplicated after we deserialize the load options free the memory used for the variable payload Fixes: db61e70e0d2a efi_loader: efi_dp_from_lo() should skip VenMedia node Signed-off-by: Ilias Apalodimas Reviewed-by: Simon Glass --- lib/efi_loader/efi_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 65d2116381ae..916f43da26c7 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -74,6 +74,7 @@ out: */ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t *guid) { + struct efi_device_path *file_path = NULL; struct efi_load_option lo; void *var_value; efi_uintn_t size; @@ -92,11 +93,11 @@ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t *guid) if (ret != EFI_SUCCESS) goto err; - return efi_dp_from_lo(&lo, guid); + file_path = efi_dp_from_lo(&lo, guid); err: free(var_value); - return NULL; + return file_path; } /**