From patchwork Sat Oct 22 07:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1153120wrr; Sat, 22 Oct 2022 04:04:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7LrMuzy/FozEPu7x81Y2DKCL3sB7F2mCmRlTujUDzHjMbUiMkkrVKG9vgROEGbggZYQtwE X-Received: by 2002:a17:907:9611:b0:78d:bb06:90a3 with SMTP id gb17-20020a170907961100b0078dbb0690a3mr19571582ejc.233.1666436689217; Sat, 22 Oct 2022 04:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666436689; cv=none; d=google.com; s=arc-20160816; b=zgoLCj6khPVhOKE1VFuBXR5nimFvMkogQi7XDj+3NhTyYmJnLBHYFsLlHZuu3vSUE7 EfQ8bUMe+GZ+mEA2AKGDmsnEEGQbIaFigzhUtNxDbjOxgWL6VNnD6nQnoNBd1n9lwu4A 0ZiuN4JJL/j4PRqDfz5l9hCBIEPXiDzv362jl6TW8S6UF9UzigrJdkcFNyLWXo1yzR99 Z0hCMT+7bBhTqiKmI3PcdvPVWeXMZKkiEw6HRJSKy4l2I6LL3gf1obgIFNXhNhOoXeSm b5bqEz/9vmh0IV5XY/vJEYaV4mvQEx2piZ64wNKMp1ChWJ6iEXszoLwCv75ORPNPoK9z DlPg== 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=U4Y0hspfEMfJjdqOLNZFbRw5yUFpD4YVF8HYyB0iNLPyo8V5nVpMDftK9JJYmV9rcm IkFogNR8bjRQVvaiwcZfhy+e0oPQn89gLAOYyyRPrnPHXYoMJcbdMzMD77K8Fph/H5o/ qSGnjStGta/UwLYYNMv9XDpR9ogVZyvSuIalKhdd51JhxAw3vPPsKwnkH6SEzR418bxG 6DO80D2YWaX3+h2UNiVBvbk8N+ABGRg88uUJvtSaCibkHGxikCRnqtO8yL+NW26thuVm 2NZPYKu3OApscMs6H4uXAGwA7pA2rLUylzgGbY8+BHFQ0wFJUWA9RirktPnKE4ABkBFq 7GSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pnufLew+; 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 g39-20020a056402322700b0046181f0e503si998581eda.209.2022.10.22.04.04.15; Sat, 22 Oct 2022 04:04:49 -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=pnufLew+; 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 S230121AbiJVK6Q (ORCPT + 99 others); Sat, 22 Oct 2022 06:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230446AbiJVK5x (ORCPT ); Sat, 22 Oct 2022 06:57:53 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC14C319B88; Sat, 22 Oct 2022 03:16:35 -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 sin.source.kernel.org (Postfix) with ESMTPS id A3E46CE2CB3; Sat, 22 Oct 2022 07:59:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 609DBC433D6; Sat, 22 Oct 2022 07:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425548; bh=X1wE11PrAAWw40XctTtBRMrMg9csj3krl4R38bk5NqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pnufLew+vBVIRbhblDTV5C8t1OhIkXxHDh703gR1UrZDT5Z+YWHuBAkFeE0Q7LmGP NiSJGA2FzvpcDA96TcQz1j2pQlJssvEnfpM6LIz2HapvTPOLg67pKfr7HdRHyyl3uE P7ITTgN3v7Ll5NnKZ/uGa7NOnEZmFOaOGiqtxmUQ= 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.19 538/717] selftest: tpm2: Add Client.__del__() to close /dev/tpm* handle Date: Sat, 22 Oct 2022 09:26:57 +0200 Message-Id: <20221022072522.125914615@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@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?1747385517731214092?= X-GMAIL-MSGID: =?utf-8?q?1747385517731214092?= 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()