Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2886772rdg; Mon, 16 Oct 2023 19:35:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEDsb2/Hzj9q8Ttt0QxlAqzs7XbQe+wb/x3pK8qhgVUDP1+jr/3H6aue2XxZHEGjsughbt X-Received: by 2002:a05:6a20:748d:b0:13f:1622:29de with SMTP id p13-20020a056a20748d00b0013f162229demr898582pzd.7.1697510111248; Mon, 16 Oct 2023 19:35:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697510111; cv=none; d=google.com; s=arc-20160816; b=037pgsXfSzJ2efcrbP7/ZHUuNm6wDmwROPG9s8EgK6kUQ36xNIuh7bQgHVCv4WYXxf knLUQMBVGRZ5bejvUDZTTIiwJ2w7J8WxA75tGXFl1lfRw/6xHyo4fdhSQj83TFhWU4Of 6UAR7wE+vZMyVTUmOYGJkv1SkjA8uq2dHSD0Ac6NXshFXMUTCmyviLdbrA4OT/d2uzIY Zubq5qd+ek8t9RsoFWNZKXXN7DXoacMzhHIbVDlu+tHUGvcquBiD6fH+OwWhmcwXQBWj +Y59Qo8iYgscA+Z6MZJXpSwkoKncofIq0cgY/Zx4aTPt0hBlQsrsH49R8ByDt+TMvEGz kjbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=3G8FQYeyMkgLxp/t+eZD1sF6LHJwx2qnqHouMd4CfZM=; fh=rT8iZo30uZLDBCpCWcF3f0dTm+CgUSIDrcOZdst3lao=; b=uPGpLQvQXIEosoQVm0/9BzLLbcU3bdtrbyWPGmO1ku6y+LPz+DpkfW/NkohDcuuGYr 5mEjpczJg8mwmrB3T4ngE8dqBgylD6072UYDKEAzojrzw3BdGh4MlqLrbQKP8C2GFXPS BIpbHs/T3rzl+IGMyaatrmBsrgHCbYDV7S4z9YejvOVbLoBqerXRO4qYH9/LQKaGGUFN eAjT2BDeIlmyKEBTVsk4q66A0ie84s9+UvuiuuKWi8Cs9t4477gvFxP9amEK+BZ1e1Op uT/Na+8AurZ8LKzAVlBbRWODXbzt/I1kF9ZX0bb6ZqBRVFB2QuSASvsxz0OVCl7EiDIq K/Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o17-20020a170902779100b001ca1b6f296fsi712268pll.239.2023.10.16.19.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 19:35:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 9FCB0803079C; Mon, 16 Oct 2023 19:35:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234032AbjJQCdu (ORCPT + 99 others); Mon, 16 Oct 2023 22:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233838AbjJQCdt (ORCPT ); Mon, 16 Oct 2023 22:33:49 -0400 Received: from cmccmta3.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7EA2DE6; Mon, 16 Oct 2023 19:33:43 -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-app09-12009 (RichMail) with SMTP id 2ee9652df2866ea-04f45; Tue, 17 Oct 2023 10:33:42 +0800 (CST) X-RM-TRANSID: 2ee9652df2866ea-04f45 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from ubuntu.localdomain (unknown[223.108.79.101]) by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee6652df284b30-35be4; Tue, 17 Oct 2023 10:33:41 +0800 (CST) X-RM-TRANSID: 2ee6652df284b30-35be4 From: zhujun2 To: shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, zhujun2@cmss.chinamobile.com Subject: [PATCH] selftests/efivarfs: create-read: fix a resource leak Date: Mon, 16 Oct 2023 19:33:35 -0700 Message-Id: <20231017023335.7874-1-zhujun2@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Mon, 16 Oct 2023 19:35:08 -0700 (PDT) The opened file should be closed in main(), otherwise resource leak will occur Signed-off-by: zhujun2 --- tools/testing/selftests/efivarfs/create-read.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/efivarfs/create-read.c b/tools/testing/selftests/efivarfs/create-read.c index 9674a1939..6812104a5 100644 --- a/tools/testing/selftests/efivarfs/create-read.c +++ b/tools/testing/selftests/efivarfs/create-read.c @@ -32,8 +32,11 @@ 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