From patchwork Mon Oct 24 11:31:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp459024wru; Mon, 24 Oct 2022 06:38:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4JXY2PoKTXusNiWKQn1ols9kh+vZYQT6EIEwDlY+j4ybXWCbxtA6/+Qg5iQNbQvgixxvIz X-Received: by 2002:a17:906:fd8d:b0:780:997:8b7b with SMTP id xa13-20020a170906fd8d00b0078009978b7bmr28143918ejb.635.1666618713371; Mon, 24 Oct 2022 06:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618713; cv=none; d=google.com; s=arc-20160816; b=EtyEyAoPqc7Ee4NFiRwnrpBCK2RIX/gRx7ALIZhfO6uY/YdkTWXWgmSydOJ8MtBKd2 zHcnmPweey4Hytm+hbCNikP1g/176bSOV6zaQRhLvZKe9gekILy8tY527LUJGfWJ3Hst ihipSjTT0buG/xIr47h+XqAFYsngbE3ciEiQ8fATjectvWrOxpVJbT8a7CIPAu5OoqJe fjlrJiAqw1LqvNgP9RNHJGFZDiIbDba6iijX8bxG7bKPslDbBapY16t6iV9kWj8RXOfX nVGxsZW5yN6Sl03WQa+UerlKS3gnloto6E1bux5gBX3kQATXC/vaMx7/9Mx8foDV6+U+ JquA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qlt9lT4yKE11AXak/uwiVWcQH6N8U4aMfHMr/RU2qik=; b=hqP8j4W+mNfzcT9Ootr9glm6DxX3Nsenml5vDNDiA7V7E4owTvlyEByD3tm9CtSEAn pwGNQtms4jQX0xOYE3U24Vf1s7sNZfRj8ipiMoWq2gA71y7BVvG0JJg6XZi7VVg4VpgX 7huZekm4v/UEobp4y9Itph/sL9OG2oORhyKi91i8sraOpckD+MJlFGLowOou7SG6Vzfk a+RkZb9ZGQI5pybWhS1YazhBTay3U/yc8fQukFOSejx9f1IMPfj1byDIJQcxBi6OfaEZ 5zlJvImsKAzx5da4QxKKvGGt4/6dkcnfKd2yzaTofRQ4veaEbjcK+QqVDph3Kz1XqP9h Ev7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jOJwNlQk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb2-20020a170907960200b007882926c090si33405532ejc.773.2022.10.24.06.37.54; Mon, 24 Oct 2022 06:38:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jOJwNlQk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231294AbiJXN00 (ORCPT + 99 others); Mon, 24 Oct 2022 09:26:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233747AbiJXNXh (ORCPT ); Mon, 24 Oct 2022 09:23:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A3A5072F; Mon, 24 Oct 2022 05:30:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DD4EB61328; Mon, 24 Oct 2022 12:28:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC79EC433C1; Mon, 24 Oct 2022 12:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614523; bh=SQBhvpbr67nNnwBS9iLoISYpMqP1aXfZOUUFaVU+bMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOJwNlQk/bc7Y1f4MO3jGG0G262z/aomhlQ8tcnOdXvb2qkRDQpvERoNZxWn3MZ3M i8yb/Vs/Ma4coqK8bEWnVjc2o8QmHuuOwI7K8KQZ0f7vd98YwgGtVzWKIxy8slXcFv 5TSAZkTou9cu+CbNhcwOz0qDLJ9WFGd69zzjVwCo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org, Jarkko Sakkinen , Stefan Berger , Sasha Levin Subject: [PATCH 5.10 294/390] selftest: tpm2: Add Client.__del__() to close /dev/tpm* handle Date: Mon, 24 Oct 2022 13:31:31 +0200 Message-Id: <20221024113035.525923548@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747576383718629126?= X-GMAIL-MSGID: =?utf-8?q?1747576383718629126?= From: Stefan Berger [ Upstream commit 2d869f0b458547386fbcd8cf3004b271b7347b7f ] The following output can bee seen when the test is executed: test_flush_context (tpm2_tests.SpaceTest) ... \ /usr/lib64/python3.6/unittest/case.py:605: ResourceWarning: \ unclosed file <_io.FileIO name='/dev/tpmrm0' mode='rb+' closefd=True> An instance of Client does not implicitly close /dev/tpm* handle, once it gets destroyed. Close the file handle in the class destructor Client.__del__(). Fixes: 6ea3dfe1e0732 ("selftests: add TPM 2.0 tests") Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Jarkko Sakkinen Signed-off-by: Stefan Berger Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- tools/testing/selftests/tpm2/tpm2.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/tpm2/tpm2.py b/tools/testing/selftests/tpm2/tpm2.py index f34486cd7342..3e67fdb518ec 100644 --- a/tools/testing/selftests/tpm2/tpm2.py +++ b/tools/testing/selftests/tpm2/tpm2.py @@ -370,6 +370,10 @@ class Client: fcntl.fcntl(self.tpm, fcntl.F_SETFL, flags) self.tpm_poll = select.poll() + def __del__(self): + if self.tpm: + self.tpm.close() + def close(self): self.tpm.close()