selftest: tpm2: Add Client.__del__() to close /dev/tpm* handle
authorStefan Berger <stefanb@linux.ibm.com>
Tue, 20 Sep 2022 13:15:18 +0000 (09:15 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 10:35:29 +0000 (12:35 +0200)
commitb6b87460f4eb1ace0c15e39f62d597bd5692b80d
tree27ee1fe70846223667aae53f08bd20a9ad329baf
parent497d736784e58f6a73ded91271fdbc95a224202b
selftest: tpm2: Add Client.__del__() to close /dev/tpm* handle

[ 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 <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/tpm2/tpm2.py