From patchwork Wed Oct 19 08:32:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5145 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp253286wrs; Wed, 19 Oct 2022 03:56:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yq0/OEV0+rE1JxDM5p77f0OrsU5dr6Gfws3mtaOnysUgqCvWOa0zlHPl/EiBAu+KHLczp X-Received: by 2002:a17:907:7b8b:b0:78d:cee5:3145 with SMTP id ne11-20020a1709077b8b00b0078dcee53145mr5946966ejc.537.1666177017141; Wed, 19 Oct 2022 03:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177017; cv=none; d=google.com; s=arc-20160816; b=eZMrW2C+CxvU8z2WDpHY2L/VNDqOk2gRmCdyijZGRnaWnzanov05T6xK7i5Nhuzad8 fbaMaK60cmALENA44baih91gH+kCTz4/LkQ1fH15ezSIzlSfLvgrQIPIwqHkatQbn03E vZso0NDxqDWMfYUGkcvdhP+0jANaYRHt7DjJVUZrikWrfl7i0lrXFe3N5BuSU5dA7tbx C7B9Cj+XY0/feRvuTb/yDTYnWUHPlf6e6ZYl0ZBn8cbipQdvd5Nx7AHkmYRecyPFljFo qtj6STmRbj29gVbF7WFHlndLJ6W48ne0UbswBBs84txw3QHeM3g+qBHHtcT3zu9wpL4+ hB0A== 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=4vRJUTUzwjYB2roPGkBz4trD4wxoeZa0gezVN8vh6Qc=; b=vsh29L90VEDG3kPwMV1orqBwSt36j+G4rON9uMLauCaxydz+hyDOJC8rUBvpEZx6Ip 3HjpB2KTCypYZFWGofWWOMyNnJwhQGpj3Qv+0lXvd18L9r2FTyKctWimWyZMVO7+OABM 6qTZQBZo1UyMJlOGcy6O6EKuOTi5fL4lR5FZ1xAucWAoKJrsd+xPr9JUUcg2JS7Rz2FN OXK9kyZ/KRoNQQTherkZtBoGpD+c9BYY4N1mSpLkODH/G7XPo/XWAT8C7NFpeZgCN3F+ XT7N1hsAca97fUdAGk9M6MpUXKDHvZy9Fyjs6dkrPZ7TWRJpbpGyhxwF5rlz8PIy6wWu SjXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rCQFj+ur; 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 dp18-20020a170906c15200b0078bec673145si13661098ejc.519.2022.10.19.03.56.31; Wed, 19 Oct 2022 03:56:57 -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=rCQFj+ur; 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 S234505AbiJSKz7 (ORCPT + 99 others); Wed, 19 Oct 2022 06:55:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235073AbiJSKzE (ORCPT ); Wed, 19 Oct 2022 06:55:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 428E616087A; Wed, 19 Oct 2022 03:26:40 -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 ams.source.kernel.org (Postfix) with ESMTPS id D5CB1B82491; Wed, 19 Oct 2022 09:07:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E71AC433D7; Wed, 19 Oct 2022 09:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170446; bh=X1wE11PrAAWw40XctTtBRMrMg9csj3krl4R38bk5NqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rCQFj+urJjHODUMVjRzI/X/dNQItzdRh/ycpQd3Y4Ljqulm03BMDIUNs7GO4ckYsQ IcHVQhCHXFg13RFKVbfvApU/87afXvMV193LZBkxum9+FZdT4rYVAUcAOoL+mBt3KP My5u6YD8+7D2bujuprMYFFckZZiKjiEPQJ4LUtZQ= 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 6.0 658/862] selftest: tpm2: Add Client.__del__() to close /dev/tpm* handle Date: Wed, 19 Oct 2022 10:32:25 +0200 Message-Id: <20221019083319.039227250@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747113231614670128?= X-GMAIL-MSGID: =?utf-8?q?1747113231614670128?= 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 057a4f49c79d..c7363c6764fc 100644 --- a/tools/testing/selftests/tpm2/tpm2.py +++ b/tools/testing/selftests/tpm2/tpm2.py @@ -371,6 +371,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()