From patchwork Fri May 14 08:00:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1478346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FhLYL1fKZz9sVb for ; Fri, 14 May 2021 18:00:22 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lhSk6-0004vi-VR; Fri, 14 May 2021 08:00:18 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lhSk2-0004sZ-SY for fwts-devel@lists.ubuntu.com; Fri, 14 May 2021 08:00:14 +0000 Received: from 112-104-30-83.adsl.dynamic.seed.net.tw ([112.104.30.83] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lhSk1-00060A-Qs for fwts-devel@lists.ubuntu.com; Fri, 14 May 2021 08:00:14 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] uefirtvariable: fix memory leak Date: Fri, 14 May 2021 16:00:10 +0800 Message-Id: <20210514080010.9278-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Also add void for the ioctl which is intentional ignore return for deleting variable. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/uefi/uefirtvariable/uefirtvariable.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index b756ac96..f5aaa5fb 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -2223,7 +2223,7 @@ static int uefirtvariable_test9(fwts_framework *fw) /* delete the variable which was set */ setvariable.DataSize = 0; status = ~0ULL; - ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); + (void)ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); variablename = malloc(sizeof(uint16_t) * variablenamesize); if (!variablename) { @@ -2300,6 +2300,9 @@ static int uefirtvariable_test9(fwts_framework *fw) } else fwts_skipped(fw, "QueryVarInfo runtime service supported, skip test."); + if (variablename) + free(variablename); + return FWTS_OK; }