From patchwork Thu Dec 7 12:36:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 751069 Delivered-To: patch@linaro.org Received: by 2002:adf:a499:0:b0:333:3a04:f257 with SMTP id g25csp397390wrb; Thu, 7 Dec 2023 04:36:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWoqonn8+M7Hi0PXd/mmbIcAfg+gykvVdGhTTR1val6xjiK32bHo02mF8M7aH1Q/LjbvVQ X-Received: by 2002:a2e:9d94:0:b0:2c9:fda7:1ad0 with SMTP id c20-20020a2e9d94000000b002c9fda71ad0mr1338461ljj.77.1701952604619; Thu, 07 Dec 2023 04:36:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701952604; cv=none; d=google.com; s=arc-20160816; b=qCrma5zlsQl4PYlCWe86IBu05cio+l5sijIU23nCp3PPCajoHD03i6Sc3C8uJRko6L Z/vyDEFbXuRaJG+vBKuSUhHfIefUXp4gkrOG+AwruKUq0HWptJg7rJjNolxh7KCGEyJk Dt/DUE4ot5xnaTiXJFsvnyQaeyU6DJyX7ZD+h2QZtCrqLDSla5QGO5/y5N5j+e7wAAkc GEFqUPaxX9UepDJMuBeVyjcvN1EEqzSV8AFi+DcEz9RzaFksMILPMUd6apsxl5QqKgxT UNBHhDKZYo5kGMKs4clFzdvcMIUOQyV895mL0v/j56c5vP3/AgZjZvX9be9JpNmyS6qB 5M7g== 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=okhtmQk7THfQQG6Mwhe/BBQxa8lXBiFZZmSgVs+fIUU=; fh=w81bbTLr0lUg+VHB+gXXD0h/KqkBqBSSTwyd71qOwLM=; b=wgGtaa2vulMxSiCqUxDAwgObYYd5kRJWkgZiJ0SinM14MA5MOE4NLFbs6BH3uSF/YK 8LwaNz9MBUSutxZMJnrhSqzZaN1h50bCNECxskUyLuZApTn0fsBz93/emOwmB6zuB3qI ekkUHmcnHc3cQPvqAiqQUVcHfomV7F9MBk8kowaPy0gngf8owRfVO1Mw+CoJLHN8zbDQ HfhjkUBvImlAZoirmP9yjUTr4t7fK9XO2Dxbx86vUb3bKdWteddelbSFIxrCyquEM2V2 gAoHYrX/prTvKh8m1rRHlgALqw9ccy/XZ8QrBdo9ObK34sz0IkcUWbkwCKm06aHu8dpe vHvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=efYoRrYm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id u24-20020a2e9b18000000b002c9f6a36a6csi452387lji.293.2023.12.07.04.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 04:36:44 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=efYoRrYm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DFEC87250; Thu, 7 Dec 2023 13:36:43 +0100 (CET) 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="efYoRrYm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 44CC887250; Thu, 7 Dec 2023 13:36:42 +0100 (CET) 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-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 60E0687185 for ; Thu, 7 Dec 2023 13:36:40 +0100 (CET) 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-wr1-x435.google.com with SMTP id ffacd0b85a97d-3316a4bc37dso865693f8f.2 for ; Thu, 07 Dec 2023 04:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701952600; x=1702557400; 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=okhtmQk7THfQQG6Mwhe/BBQxa8lXBiFZZmSgVs+fIUU=; b=efYoRrYmAjn1QmGszXorB0jmIHtI6bRO0HtL9LcCxAWcTgNgrH+eOUR4oSOnstDxIq D5JOYRip8p9CV4cQszHMZaky203U2eB9qUaA2emKEJvLrDDJQ7+Vskkbn6gX7EwPiY49 8o/O6KG7Ua8iw51WqQGNGe5Kr3tzu5sAv3uQf87CCj03f6b1Z4mNWoT2XrB8Q0Mw4yJi QTgTP2Xdpv1uiRMvg9jw70D5dCThZ99iatryKrdh091zXvX+/lnEdQsVfCEyjLLXBK4A g94n0sz4XJygTHQ75V3WmHVpTQSCV+VY25eVTIEU62DofpMu8EAy3LjRfCbvvWGJDMhr B3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701952600; x=1702557400; 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=okhtmQk7THfQQG6Mwhe/BBQxa8lXBiFZZmSgVs+fIUU=; b=SSdKY6nkpoiqD+OIITAHzEia7hYlSdQN1cpWuyXEBA7WXBvVmugv0dU5z4lbTyAQib GVtsbsenrlzw2uUQMRpoM9C/BfZDKai/0VSj9y0eoA/m6i/Sn6nmBMZt6kVcdRZthed2 aVcd0Dy0/yBmnLYknVGZCN7UAte7oa9caBIA15aoWFvB7umzrWl3QNaLCL6ENIOkfR/X qK7zJtYjgHQ/z/eokz/h1EGNVPYHtfWOzgQ+adkCLgqRDunpeQ4XmUEf+8JFVCVEqyT6 VoxjxMdQuyQ0UxbUUblLzU/ycsQiL5RHEuimtcH0odVs2yMKMfPVX972gdzR7nGuBWtL nS5Q== X-Gm-Message-State: AOJu0Yw6x4QRJlUAxCYHf761eo72xg5j9NQrnLIngwlEQEuQrn6+nCM2 wWmzTlRqYLQIebB9O4+LyYFCkQ== X-Received: by 2002:a5d:4208:0:b0:333:2fd2:4ae3 with SMTP id n8-20020a5d4208000000b003332fd24ae3mr1588825wrq.95.1701952599840; Thu, 07 Dec 2023 04:36:39 -0800 (PST) Received: from localhost.localdomain (ppp046103111243.access.hol.gr. [46.103.111.243]) by smtp.gmail.com with ESMTPSA id k18-20020a5d5252000000b0033330846e76sm1325848wrc.86.2023.12.07.04.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 04:36:39 -0800 (PST) From: Ilias Apalodimas To: sjg@chromium.org Cc: heinrich.schuchardt@canonical.com, Ilias Apalodimas , Mark Kettenis , u-boot@lists.denx.de Subject: [PATCH v2] bootstd: Fix a memory leak in the efi manager bootflow Date: Thu, 7 Dec 2023 14:36:36 +0200 Message-Id: <20231207123636.26264-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.40.1 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 has to be freed after the value of the variable is consumed. Free the memory properly Fixes: f2bfa0cb1794 ("bootstd: Make efi_mgr bootmeth work for non-sandbox setups") Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt Reviewed-by: Mark Kettenis Reviewed-by: Mark Kettenis --- Apologies for the quick resend but the previous patches wasn't compiling due to the missing #include Changes since v1 - Add #include since it's needed for free() boot/bootmeth_efi_mgr.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.40.1 diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index e6c42d41fb80..6428c096d7f8 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -16,6 +16,7 @@ #include #include #include +#include /** * struct efi_mgr_priv - private info for the efi-mgr driver @@ -65,6 +66,7 @@ static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow) bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid, &size); if (bootorder) { + free(bootorder); bflow->state = BOOTFLOWST_READY; return 0; }