Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3249321rdg; Tue, 17 Oct 2023 08:47:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW4OLBgEKyRVmGAPJsRazg9b3unfpSGrqNaYnf2ehfzxzaFzva1Nd2xRSgbFd/7yK0C2PI X-Received: by 2002:a17:90a:fc84:b0:27d:8457:e541 with SMTP id ci4-20020a17090afc8400b0027d8457e541mr2122878pjb.49.1697557631914; Tue, 17 Oct 2023 08:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697557631; cv=none; d=google.com; s=arc-20160816; b=z3zm1+WxIx3q/NEs12okrVC1v1sgN+TdYU2KryUdTcHwnp1o9plWFZsXG7BtKSQ6Dz hh6+1e8Z2XSbY1cXf36My84+vQQoSup1VNrzuOORv7pIVVyba8qzw/MQD2jVdt7ltFtN 4tr8X61R0oJgHVMjyf3YR8kqqwpgZ+tv1EYy9JDQ1pBxyIS3BvVy0xCuvU5pfbTHSSy1 c9Gbnr0JFR2lak/Z/uoXR26142n49KqUzhTsqfQwzJJAvnHDlcTNsBGF8vq+sGXfdDGg +0czTTMJs7auBeXIkQnzo0NcHVd44moddjuJu0eJYuULZqtopP5iPzCDEodTDXmiRqfl LQKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=qifLUWrkmypuE1HSNNdyFzpD4fELvix1NB9KRDxZL6k=; fh=0+j2cy7kwNMq4noW/nqZjvULDxBfomZcrf6gjtgZZv0=; b=urukMYOc35u4uvEjr+5uOqcF2cAWYgSuND+334V4jdW+1h6M9Vb5qesKd6taRYg4dY 8yGBCVwVOQKDzIcMEnurHcyHrTKKiHvxA1qkjj3SvqqbpxhgqJjyI/ezTIrPMbLfr1In FtzWUDPy+e3oDbIk0yPasE54+FypvHd/MGVIPP+WDVagB/o8LIALXSaPVnULwck4JFGT jSLSXyAG4Db8l5W9t+w07e8dT6buozC5JB+uhSqaMOqUyGV/Y/E1rz9Yv9cRialz1ieQ 2aEzR04Rp7JMwVhaMkejN2g49bAC4ByOQMhCsv7q7X7YkhjT94ZxzscNszd7J7c4Vfaw X/pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=K2yfEisq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id in7-20020a17090b438700b0027d2c3f25a7si1894617pjb.80.2023.10.17.08.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 08:47:11 -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; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=K2yfEisq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A49AA80CF50B; Tue, 17 Oct 2023 08:47:09 -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 S235098AbjJQPq7 (ORCPT + 99 others); Tue, 17 Oct 2023 11:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235133AbjJQPqu (ORCPT ); Tue, 17 Oct 2023 11:46:50 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E592F13E for ; Tue, 17 Oct 2023 08:46:48 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7a66555061eso4346939f.0 for ; Tue, 17 Oct 2023 08:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1697557608; x=1698162408; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qifLUWrkmypuE1HSNNdyFzpD4fELvix1NB9KRDxZL6k=; b=K2yfEisqlKZqRVCJlCswRZR7ZE34IYOmxwd2QVY71uccQEJomx59oVxDDvMC57KEQb aN2noaz0bVQEOiLrXr2PAbCwSlqoPOpu7jxnXmuNEQfbSZ1lJf+sh1A7B7vMrM6TT0iN voMHn4nQw5YpOrun58BVrnQ24SmYg3aymmboE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697557608; x=1698162408; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qifLUWrkmypuE1HSNNdyFzpD4fELvix1NB9KRDxZL6k=; b=K95ccu5g/PcURwWCa9g763prdN7MhbgGJ01ls2zwL/Ps41ga6tfLta7tncdokadH0f aAbB5h36ReeT9CubngScGA3xntot8Mrc7uDHMB6CBARUK4C7+lUFTChduNKgERbvv+2f ldVNmvp3N7XhysuRqsWWFG8liHWTNE8HzmrkKAP5dTNWfxhTtuZybJ8s2OS/NnW0ayDM 61JDPqSz7HhE+p3FQT4y7FZmmRszAV9slrsaeE/WMJu/JYBr0EjhdMZtVLKaZCS2eCT4 nw/HQP7V2xPi9SS3LH+7Lk+HNH2+HKi+vS2MiaT/isJJ37PQE6CQHiz33G1fGpaW4B6N ypJg== X-Gm-Message-State: AOJu0YxaJF+78EDT+9z82ifGIZeo0KtmdetQ1+hNkNqefXYihTNOiHVL hTP3wBrCaKAUsKKra9tkMPoUlQ== X-Received: by 2002:a05:6602:1513:b0:79f:a8c2:290d with SMTP id g19-20020a056602151300b0079fa8c2290dmr3348129iow.0.1697557608211; Tue, 17 Oct 2023 08:46:48 -0700 (PDT) Received: from [192.168.1.128] ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id x22-20020a056638249600b0042acf389acesm556725jat.71.2023.10.17.08.46.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Oct 2023 08:46:47 -0700 (PDT) Message-ID: <2a96e3a8-48a5-46ae-9a0c-b5f2def0a257@linuxfoundation.org> Date: Tue, 17 Oct 2023 09:46:47 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests/efivarfs: create-read: fix a resource leak Content-Language: en-US To: zhujun2 , shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20231017023335.7874-1-zhujun2@cmss.chinamobile.com> From: Shuah Khan In-Reply-To: <20231017023335.7874-1-zhujun2@cmss.chinamobile.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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]); Tue, 17 Oct 2023 08:47:09 -0700 (PDT) On 10/16/23 20:33, zhujun2 wrote: > The opened file should be closed in main(), otherwise resource > leak will occur > Did you find this by code reading or by any other means. Please add how you found the problem to the change log. > 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); > + No need for this extra line here. > return EXIT_SUCCESS; > } thanks, -- Shuah