Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3520437rdg; Tue, 17 Oct 2023 18:59:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXPqhvxKWTXoVobA6n+2kILKZpaoxJWaj2fddHQx1s3bt0NftpXWRolBBos4wTU/i/NDfQ X-Received: by 2002:a05:6808:1b0f:b0:3b2:e0f1:acf with SMTP id bx15-20020a0568081b0f00b003b2e0f10acfmr2947762oib.16.1697594388768; Tue, 17 Oct 2023 18:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697594388; cv=none; d=google.com; s=arc-20160816; b=IZAEKp/5pyzWE/a/XUnCmmk6xq5kQUtaGRGTtoUVX9F1mSutMCyCVZKDk+Sln78Gqu f0KHXCP2Z0SizZi/f2GPJX23g5cfTyDneEC6DHDpASf8lWMgrCyu1jiQV1VaccLBCJEz NIEKhBtj/2yiX1c99xA9iBBQSpeW7GDEExrom9sC9ypPmYAg8y8jn2k+8EL3bFhS5wyX vW8zOSG+nyp6nRo3gJUHR9G/DK8FprXSpg6tVt25li5AZQPWdlfMKV5Go0g2aQHqxpo0 SnKJei3ORYmPZOOND3fKdCt4YjoSG30p8+4uwY0xlOtle9xv040Rldhoxi35j66DHcy4 Zh0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=BjVcbyjH5lGJscXTeprfROQMTAIm/RCirtgVy9196w8=; fh=bimsJ23vuu7OCsCoZbnHgZoYhxVx3CPefbOwZU3lzG4=; b=MIXpyKoJQzA0OYSzGzhgJDsNhRrqCoQ4ApnDWGObHbmCx46MxMSxQZyw8PQFZKV87V FPbWmyc+OQtXE9PgdJ0V/SIYUm2yP5Rfx00qKwRIvg0MIdYfnNWipBtlX6Zv9OdTMTMW T7UETmL+JfqM/2XjihVRT8dkU90OxDgGpG0eY+y19fBGbtQWX3ZzRdsV111wPM/+uV+h o28qGT/Mfy+saZ70AXQ4zNzBu0Kpdx9fNDUCu9B8zSfig6SZF8V4WP64lvOvtpwOdUsv 4ttKh5DPclPiPjBZP/L1EvJQBBzaOEDkWXquV+sq3uQL4NtcNw6zsFk21RjDgeB2ABRt vUhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s22-20020a656916000000b0058989aa1a1fsi1050130pgq.758.2023.10.17.18.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 18:59:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9D920810438C; Tue, 17 Oct 2023 18:59:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234836AbjJRB7q (ORCPT + 99 others); Tue, 17 Oct 2023 21:59:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjJRB7p (ORCPT ); Tue, 17 Oct 2023 21:59:45 -0400 Received: from cmccmta1.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3BCE4C6; Tue, 17 Oct 2023 18:59:25 -0700 (PDT) X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app01-12001 (RichMail) with SMTP id 2ee1652f3bf940a-0bcd8; Wed, 18 Oct 2023 09:59:24 +0800 (CST) X-RM-TRANSID: 2ee1652f3bf940a-0bcd8 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from ubuntu.localdomain (unknown[10.54.5.255]) by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee6652f3bf9f61-4301e; Wed, 18 Oct 2023 09:59:23 +0800 (CST) X-RM-TRANSID: 2ee6652f3bf9f61-4301e From: zhujun2 To: skhan@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, zhujun2@cmss.chinamobile.com Subject: [PATCH] selftests/efivarfs: create-read: fix a resource leak Date: Tue, 17 Oct 2023 18:59:21 -0700 Message-Id: <20231018015921.16890-1-zhujun2@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <2a96e3a8-48a5-46ae-9a0c-b5f2def0a257@linuxfoundation.org> References: <2a96e3a8-48a5-46ae-9a0c-b5f2def0a257@linuxfoundation.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 18:59:47 -0700 (PDT) The opened file should be closed in main(), otherwise resource leak will occur that this problem was discovered by code reading Signed-off-by: zhujun2 --- tools/testing/selftests/efivarfs/create-read.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/efivarfs/create-read.c b/tools/testing/selftests/efivarfs/create-read.c index 9674a1939..7bc7af4eb 100644 --- a/tools/testing/selftests/efivarfs/create-read.c +++ b/tools/testing/selftests/efivarfs/create-read.c @@ -32,8 +32,10 @@ int main(int argc, char **argv) rc = read(fd, buf, sizeof(buf)); if (rc != 0) { fprintf(stderr, "Reading a new var should return EOF\n"); + close(fd); return EXIT_FAILURE; } + close(fd); return EXIT_SUCCESS; } -- 2.17.1