Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp255832rdf; Tue, 21 Nov 2023 01:32:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0VyKmo472DaFjzRW9t3ASzSW2SnHtTl49e3ABETYSOmBseFrxep2ZatCV4nPFy6co1pi0 X-Received: by 2002:a05:6a20:3d8b:b0:17b:2b7e:923c with SMTP id s11-20020a056a203d8b00b0017b2b7e923cmr9683849pzi.16.1700559172809; Tue, 21 Nov 2023 01:32:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700559172; cv=none; d=google.com; s=arc-20160816; b=KJHG9rCi/4ebFIj7a2eDYDy54y9qsIwzXzByulRcakUkpTx4lXB+7I8robsjOtfE8y zLok1XlcnE8vQq+fHyV6pfr+Hcr/AzSLy48TZTBKWoebT834Yq/oCtMAKCvgobT9Fp/b YSef9Huo73GbOyc77qnHbtASFLnXCXe0OoJrLsbu69GybhMtsehNab29w/TRPNDrV649 CsxBTgznZybHDY8vKeIvSwA3iw7MHdPGtAT0QQPsMeeEJXKa1Scxs65EvVxEL0Zy/BF1 Ms6RLkyYFW9t3BChDZsBbolL8/FgRlylhrCWzpncaycZ83JT3fbJtcNodYB6YrGVOKYz Ec6Q== 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=4bDZpD5DY1348MPSysR+8LnoDzQjUto+u21c7/yR6Wc=; fh=B6ttuc/1Es3/tWLEfask1iZefAELZK/z4H7MIdLoPgg=; b=Dkpi39ZsOHjg2i+K5uqUvJYJWxBl0C4Gjac0WvgR4bViTa1vg93QaXNDhCVpiv0E1X pnwciFnz1mnjSLIYpmB+Grt6GGphKsCOq6Z+yw+BVo1w2Ka4oTBMXGNfMID7wlJbnwwx uUSAAaNAe/z34e0YdAkftwjVVFHt7SpIVGUFw+1uRBX9rcKGV4ao4KhKwZ4vVWF6u7dK Za6D+rmgi0y61guoyL/rZrOjHbg6PqRDFq4XL64NlWZfQgt8ud0le+VKoktfTJ+W7rPj nrWsQUosGvyf1dlRUJrhwqQNruCN/9gebF2zTQo0mUlk+hrWwiCbczD1ScBoT2euHIKR UZiQ== 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 mm1-20020a17090b358100b0028001292940si11974226pjb.68.2023.11.21.01.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:32:52 -0800 (PST) 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 DC22C80E73DE; Tue, 21 Nov 2023 01:32:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233622AbjKUJcu (ORCPT + 99 others); Tue, 21 Nov 2023 04:32:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233573AbjKUJct (ORCPT ); Tue, 21 Nov 2023 04:32:49 -0500 Received: from cmccmta1.chinamobile.com (cmccmta8.chinamobile.com [111.22.67.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11168F5; Tue, 21 Nov 2023 01:32:42 -0800 (PST) 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-app02-12002 (RichMail) with SMTP id 2ee2655c7937287-805b6; Tue, 21 Nov 2023 17:32:40 +0800 (CST) X-RM-TRANSID: 2ee2655c7937287-805b6 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from ubuntu.localdomain (unknown[10.54.5.255]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee8655c7937a7b-cb139; Tue, 21 Nov 2023 17:32:40 +0800 (CST) X-RM-TRANSID: 2ee8655c7937a7b-cb139 From: Zhu Jun To: dan.carpenter@linaro.org Cc: ivan.orlov0322@gmail.com, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, mathieu.desnoyers@efficios.com, shuah@kernel.org, zhujun2@cmss.chinamobile.com Subject: [PATCH v1] selftests/media_tests: fix a resource leak Date: Tue, 21 Nov 2023 01:32:38 -0800 Message-Id: <20231121093238.5376-1-zhujun2@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <71465605-7179-4281-8ec8-80f741e78038@suswa.mountain> References: <71465605-7179-4281-8ec8-80f741e78038@suswa.mountain> X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_BLOCKED, SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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, 21 Nov 2023 01:32:52 -0800 (PST) From: zhujun2 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 --- Hi Dan Carpenter I believe that the Linux kernel code is sacred and should strictly adhere to C code conventions thanks, [Zhu Jun] tools/testing/selftests/media_tests/media_device_open.c | 2 ++ tools/testing/selftests/media_tests/media_device_test.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tools/testing/selftests/media_tests/media_device_open.c b/tools/testing/selftests/media_tests/media_device_open.c index 93183a37b133..ae263eb78a2c 100644 --- a/tools/testing/selftests/media_tests/media_device_open.c +++ b/tools/testing/selftests/media_tests/media_device_open.c @@ -79,4 +79,6 @@ int main(int argc, char **argv) else printf("Media device model %s driver %s\n", mdi.model, mdi.driver); + + close(fd); } diff --git a/tools/testing/selftests/media_tests/media_device_test.c b/tools/testing/selftests/media_tests/media_device_test.c index 4b9953359e40..65888ce5c89f 100644 --- a/tools/testing/selftests/media_tests/media_device_test.c +++ b/tools/testing/selftests/media_tests/media_device_test.c @@ -100,4 +100,6 @@ int main(int argc, char **argv) sleep(10); count--; } + + close(fd); } -- 2.17.1