Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp873644rwi; Wed, 19 Oct 2022 04:10:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7EGD2IjJY1tdQ0k0Q5Cq4FK3WhqS/vBMXU1oH59WbbxKcOYSJ7oDvq7toQM/2x3XD9HQc4 X-Received: by 2002:a65:6a0d:0:b0:464:4fff:2991 with SMTP id m13-20020a656a0d000000b004644fff2991mr6572057pgu.506.1666177801618; Wed, 19 Oct 2022 04:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177801; cv=none; d=google.com; s=arc-20160816; b=srYRWar33LIuZySxGD3yYiJgLixNuiPF+G1k4WUSGA6V89A7UT9UpVTitYbACCInu2 JqAQIkCLzKpnhjsdR68aUO6x/oI5wfQAgA7DboHWxFA8Anb/6GREtB62yPLVoM51McVp Tib8VtUM/BAK6OWZRoOD4mxGW6zomLd+Jjwn4pgr/FcoB3fHwA2IHwgfgHcpMSe9Kw73 TAINArFYDJ/bCfnTpBoin5ItvPah20h9eCWdLQsJ8KYrVL0OTJRJxHRetr/rSGLxGbhq SFdvhZmXgrvrDkudoi89BUGU02azIrHiVzdiZsbzBf8dAXCTPYFpkD2worBRX7ySzBE1 FFtQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a17090a6ac300b0020a84ae69b1si22726085pjm.71.2022.10.19.04.09.47; Wed, 19 Oct 2022 04:10:01 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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() -- 2.35.1