From patchwork Tue Mar 3 13:57:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Allen X-Patchwork-Id: 198028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C145C3F2C6 for ; Tue, 3 Mar 2020 13:57:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCC8D20675 for ; Tue, 3 Mar 2020 13:57:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="Qn/dIOkd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728592AbgCCN54 (ORCPT ); Tue, 3 Mar 2020 08:57:56 -0500 Received: from mail-mw2nam10on2080.outbound.protection.outlook.com ([40.107.94.80]:6067 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727121AbgCCN54 (ORCPT ); Tue, 3 Mar 2020 08:57:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MMjSFjtr8usF4aVVsXnWw0PjcNQC406OheZCZUryAzvgR0Zi/XNI44auGC3hEkTqp8wiSdYxYGbUtDS/ND3mwPJ5UX4CJu1JD9FI7q6rFaEUMNuos0ltGuPXRS+ffFyiyKLJun9kJwvYTCiQYuqGLt7REMv0iPzyo0U3qNMH9ffTTZupsPKPS+ACf4q8HMxiUrSNd7MIV0Lml2eDC0vhXKFjWOX3Vy320SsmRfupdUK2ieqPUn2wtLA4sFE09b/v+UaYeLbL1KqM6NeSiA+DSnQaZcLsj31Yiu6Cae8ZiHYnLyq7mu2LQRLyNw4uEtb+m6/w6hGevwujj1b8cNNiKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WJWKSBT/aIMsiaHAo7Xx1K4koZvC1HU6IjSKPPkAzPc=; b=YRIhMhCRXBt4rZQlQNjI1p7F/n7VKo1L5Jfuhe4q/0QrYtGNuiQxPiqmWVfVFQplbgsrgw7MCAgDOoqb8awYtUG2pIT+/311aDVFOp1vtKDkfS1/0nO/4+SJtWikAjVLYC65qbOqLqlhIJ2CXMAz/ojXTIO6zf7snHrpcReKTWkIC2tdwPyWaDaPd/uRegzYjAnSNUz701iWG7svtxF8uB8chqrsGxoD0JgCRRsS+h5Q2S5r8AC142dr9W5G1atPtYQT3SbrDVSGm1RPUmUVzGy3yh3EaelT0J939Cv5uHhKymrnofYdmYnM7LIusIsWM+6mnweiZAW416hSKKAeow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WJWKSBT/aIMsiaHAo7Xx1K4koZvC1HU6IjSKPPkAzPc=; b=Qn/dIOkdChYTk6CQsRiayZFxY4H1DwbtoLvNCW+ciBrOcMkM1lY/s+Q2pZ7TJHDezH6/MqcO/Kd3TQ206Nd1C3jWX9w1e9gxV+he5ovz6s932+KzvB92VrX5RgtOWywAdtDihJS3dSjT1WQ+XFKmTl3x8H0ZJ2eqsl0aRm9oQ8Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=John.Allen@amd.com; Received: from SN1PR12MB2448.namprd12.prod.outlook.com (2603:10b6:802:28::23) by SN1PR12MB2349.namprd12.prod.outlook.com (2603:10b6:802:2a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 13:57:53 +0000 Received: from SN1PR12MB2448.namprd12.prod.outlook.com ([fe80::4064:dc7:d9b9:1f64]) by SN1PR12MB2448.namprd12.prod.outlook.com ([fe80::4064:dc7:d9b9:1f64%7]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 13:57:53 +0000 From: John Allen To: linux-crypto@vger.kernel.org Cc: thomas.lendacky@amd.com, herbert@gondor.apana.org.au, davem@davemloft.net, brijesh.singh@amd.com, bp@suse.de, linux-kernel@vger.kernel.org, John Allen Subject: [PATCH 1/2] crypto/ccp: Cleanup misc_dev on sev_exit() Date: Tue, 3 Mar 2020 07:57:23 -0600 Message-Id: <20200303135724.14060-2-john.allen@amd.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200303135724.14060-1-john.allen@amd.com> References: <20200303135724.14060-1-john.allen@amd.com> X-ClientProxiedBy: DM5PR07CA0060.namprd07.prod.outlook.com (2603:10b6:4:ad::25) To SN1PR12MB2448.namprd12.prod.outlook.com (2603:10b6:802:28::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mojo.amd.com (165.204.77.1) by DM5PR07CA0060.namprd07.prod.outlook.com (2603:10b6:4:ad::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18 via Frontend Transport; Tue, 3 Mar 2020 13:57:52 +0000 X-Mailer: git-send-email 2.24.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8c4501bd-b91b-441c-d26e-08d7bf7ade3a X-MS-TrafficTypeDiagnostic: SN1PR12MB2349:|SN1PR12MB2349: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(366004)(136003)(346002)(396003)(376002)(189003)(199004)(316002)(478600001)(2616005)(956004)(8936002)(81166006)(81156014)(6916009)(8676002)(86362001)(44832011)(36756003)(26005)(186003)(16526019)(6486002)(6666004)(1076003)(66946007)(66476007)(4326008)(5660300002)(2906002)(52116002)(7696005)(66556008); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2349; H:SN1PR12MB2448.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KGdzdEGEtuQlPs+2+3mgryrakLi/xNL285XmpE2EQRLT1NkjJv3Il0331yGlJi72+xiz4f3COy3ar64q9/kFGcNOc04FB4Tu4hYbrDYUI2FjeqfA3gSUp6+rITq1gkeStlm5ifp+LKcInvHJqIxW1kxMkaBMzXOWjoGKKT1u+I9TMGjUF5zDbecRbqQzukIafzS+SU4HFwwIihMrm46oqzqeFd0+MmYRoINnprGdtv9Pwb0EtCgXiuCLbeeJH89w7gm1IDjZirhAr7vmQy1WxkzzfmG0s7jZFgyhzEiGPJkdT56XVvOvOjPeuB1pc23Pkfr6OESja7pUv2ojlLg+cZJvz05gZSFVAt/LgEU2iQIvAgFjFC2W5CGAOK2eimU5EVF9J/JvvJbPKYyihtUanmhgD19Gwu8J79NwS0Z5NCnx2LVtT9clVFfm7CtBYNjh X-MS-Exchange-AntiSpam-MessageData: bnf2N+2dWdY9fBPDqT1ogUmwceCEGw4WEnWGpsqcPxmIicKPzTDpLGwjer9OvomBMD6IPfEc7lG9L1gKl17+IT1HxOhO5bgixroBNwnfj3KlMXB+SVACiTu2bkTi+rOPbk+dY2ktUAralCANinr+iw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c4501bd-b91b-441c-d26e-08d7bf7ade3a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 13:57:53.5174 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Qqi3NomNjbJMU7wPxAZB1oEQCZGdTubCLDQzRmOlUMqVm5Oq9RkS2t+ir7WRvIIR+ZsJCGXyDoL4tzH9SFPlxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2349 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Explicitly free and clear misc_dev in sev_exit(). Since devm_kzalloc() associates misc_dev with the first device that gets probed, change from devm_kzalloc() to kzalloc() and explicitly free memory in sev_exit() as the first device probed is not guaranteed to be the last device released. To ensure that the variable gets properly set to NULL, remove the local definition of misc_dev. Fixes: 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support") Signed-off-by: John Allen --- drivers/crypto/ccp/sev-dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index e467860f797d..aa591dae067c 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -896,9 +896,9 @@ EXPORT_SYMBOL_GPL(sev_guest_df_flush); static void sev_exit(struct kref *ref) { - struct sev_misc_dev *misc_dev = container_of(ref, struct sev_misc_dev, refcount); - misc_deregister(&misc_dev->misc); + kfree(misc_dev); + misc_dev = NULL; } static int sev_misc_init(struct sev_device *sev) @@ -916,7 +916,7 @@ static int sev_misc_init(struct sev_device *sev) if (!misc_dev) { struct miscdevice *misc; - misc_dev = devm_kzalloc(dev, sizeof(*misc_dev), GFP_KERNEL); + misc_dev = kzalloc(sizeof(*misc_dev), GFP_KERNEL); if (!misc_dev) return -ENOMEM; From patchwork Tue Mar 3 13:57:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Allen X-Patchwork-Id: 198027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D952DC3F2D7 for ; Tue, 3 Mar 2020 13:58:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A735D20857 for ; Tue, 3 Mar 2020 13:58:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="E9rdzTSm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729307AbgCCN6C (ORCPT ); Tue, 3 Mar 2020 08:58:02 -0500 Received: from mail-co1nam11on2088.outbound.protection.outlook.com ([40.107.220.88]:6191 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729221AbgCCN6A (ORCPT ); Tue, 3 Mar 2020 08:58:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T4owdKqshwSOhazMFP+285PQwhbrbqCJMozJduJ1rJAmQnGEF8Ai6jhofDgAtT7dl6kxI0ppKxJRhunnbmntolkeprE/cCsu4+cAaN1EEus/rZwDewrO+i27iBC1gwaajkXGVybDdL5lAfnBTqAyjX7egxeOsdPn49nrt1AbQ34p755tCEg8EVgeEbgjbAkv4OlQyn250PSfAa6xZ6U3to9wdm9RpYEd+/6Spp3d0mMOsgyohXMQmcXtm7mVe4wJvN5LjYvjbb+TFiQ2LGGz5rQZz+XZWQzPPeBMpuDuCdf8lsL73jCf8zSJyyPjtdym+5/lJvZ/70XAqec4V4VNmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mxFF7ge0Np68AOeCRzrePADGpN5rxY8q+5lDAqCGYU4=; b=G3taHuilYNSQdaz8Tka8B4jURLVMD0uhNwmsDbs1tE04EmwjuorA+8BtumOG32dXfLa3M9y2Znm7RCbq4hWBg0oKnrfrZ51DRcxZxpZF6MkQ/McXX/cKcMaibqKVt/fJeFtqOjwsnn8aI8Uylo1/7pOXBPv2iuRd2cqd14Tlkn5qI0iKGN+IbgIiZwY+8/r4wsxKLkNPYHduTRGpru6RByTcbfrmnYPiNLB0ElN5TAHJo+gjk1EWlGNcsLmEV4wwBkt+5h/c2V4SQG1RZlkTAdgIIraIzIs5VJufq6LNZWnlffJ+T8+y2rMvcsK4fIO2eI9MIEO2dSc8FOWjDeGMYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mxFF7ge0Np68AOeCRzrePADGpN5rxY8q+5lDAqCGYU4=; b=E9rdzTSmxfriB/kDRWYEMhED1CcxONnKBSg77PpTQGDaU1agKSX6syFtlBNj2bG9XysVwlmSf92W6F+djomtxTwhjSFNpnM04OwN7kSmOBJ510gWfqFhfMZwn8JoYBsmEsvXz/k4twafw45GvUGqZH9Oltr31OPfeY9/DqcpPWM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=John.Allen@amd.com; Received: from SN1PR12MB2448.namprd12.prod.outlook.com (2603:10b6:802:28::23) by SN1PR12MB2414.namprd12.prod.outlook.com (2603:10b6:802:2e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15; Tue, 3 Mar 2020 13:57:54 +0000 Received: from SN1PR12MB2448.namprd12.prod.outlook.com ([fe80::4064:dc7:d9b9:1f64]) by SN1PR12MB2448.namprd12.prod.outlook.com ([fe80::4064:dc7:d9b9:1f64%7]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 13:57:54 +0000 From: John Allen To: linux-crypto@vger.kernel.org Cc: thomas.lendacky@amd.com, herbert@gondor.apana.org.au, davem@davemloft.net, brijesh.singh@amd.com, bp@suse.de, linux-kernel@vger.kernel.org, John Allen Subject: [PATCH 2/2] crypto/ccp: Cleanup sp_dev_master in psp_dev_destroy() Date: Tue, 3 Mar 2020 07:57:24 -0600 Message-Id: <20200303135724.14060-3-john.allen@amd.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200303135724.14060-1-john.allen@amd.com> References: <20200303135724.14060-1-john.allen@amd.com> X-ClientProxiedBy: DM5PR07CA0060.namprd07.prod.outlook.com (2603:10b6:4:ad::25) To SN1PR12MB2448.namprd12.prod.outlook.com (2603:10b6:802:28::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mojo.amd.com (165.204.77.1) by DM5PR07CA0060.namprd07.prod.outlook.com (2603:10b6:4:ad::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18 via Frontend Transport; Tue, 3 Mar 2020 13:57:53 +0000 X-Mailer: git-send-email 2.24.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e3236002-00d5-4163-c1f6-08d7bf7adee7 X-MS-TrafficTypeDiagnostic: SN1PR12MB2414:|SN1PR12MB2414: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:480; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(346002)(376002)(366004)(136003)(189003)(199004)(478600001)(26005)(6486002)(4326008)(8676002)(81166006)(36756003)(8936002)(16526019)(6666004)(52116002)(7696005)(44832011)(86362001)(186003)(81156014)(316002)(1076003)(2616005)(66476007)(956004)(66556008)(66946007)(5660300002)(2906002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2414; H:SN1PR12MB2448.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G72HIWkURfMExqwBejq6x39yEfq4/JG6gctWxFxcE3HiCk2vdiFfj3GHFvBcFHQOWoqi3JN3jjOflAyadCWXy6UkmCaLUSMXocFAMrN/SwBV1T7PaKnwSntuVfp945RQJ16TjSlclRM0TuHFMIhrIpom0FNDoiw5TY63fsVH17u55DayXYw1eMD675Josg7Qd9uSLTyJRVOlWekUlqpgY6AagpDcs1UdtyBX1lME3jfDxUpiWeFEzG+HVpAVnbG4WjoCVDVJN7KrBEVmz3U1lkXF0gBWCeL4FIH5een9IKtYzyt3ynsfwLF+Hu/OyB0Z4DuiFuAE1i9keKUyerpEsvJ9gXLae6zj1vx493OuwFyRa+QfFwJV5fjftzggSzT1n4jZmlgOTnwUO1UsdWerKKJ5vsnB92eHgUIkm/JkQtJ7YB9an035ynRvargQdPIm X-MS-Exchange-AntiSpam-MessageData: eamE7WfJ8T7UF++26B1K2vlWGTFCRfVvdk4VkyJGyy91vc6hwVw2+So4WcLBNHMG6iFsz2Oi10Yja7ZYVXAWajrVxZwqWiYeKO9Z028GmkANYIbwPxUAHuFiI3LAgOGGAct5SKS5wqEuwAXkUKNjNA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3236002-00d5-4163-c1f6-08d7bf7adee7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 13:57:54.4829 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZB+WIgCHiRPQ3xVA35+SYOv0SHZ5idGstljhaQUydSd/EraMNpY+7j67yUXn3hA3y1idYo3bkDv3VjAz/6qg6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2414 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Introduce clear_psp_master_device() to ensure that sp_dev_master gets properly cleared on the release of a psp device. Fixes: 2a6170dfe755 ("crypto: ccp: Add Platform Security Processor (PSP) device support") Signed-off-by: John Allen --- drivers/crypto/ccp/psp-dev.c | 3 +++ drivers/crypto/ccp/sp-dev.h | 1 + drivers/crypto/ccp/sp-pci.c | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index e95e7aa5dbf1..ae7b44599914 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -215,6 +215,9 @@ void psp_dev_destroy(struct sp_device *sp) tee_dev_destroy(psp); sp_free_psp_irq(sp, psp); + + if (sp->clear_psp_master_device) + sp->clear_psp_master_device(sp); } void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler, diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h index 423594608ad1..f913f1494af9 100644 --- a/drivers/crypto/ccp/sp-dev.h +++ b/drivers/crypto/ccp/sp-dev.h @@ -90,6 +90,7 @@ struct sp_device { /* get and set master device */ struct sp_device*(*get_psp_master_device)(void); void (*set_psp_master_device)(struct sp_device *); + void (*clear_psp_master_device)(struct sp_device *); bool irq_registered; bool use_tasklet; diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index 56c1f61c0f84..cb6cb47053f4 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -146,6 +146,14 @@ static struct sp_device *psp_get_master(void) return sp_dev_master; } +static void psp_clear_master(struct sp_device *sp) +{ + if (sp == sp_dev_master) { + sp_dev_master = NULL; + dev_dbg(sp->dev, "Cleared sp_dev_master\n"); + } +} + static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct sp_device *sp; @@ -206,6 +214,7 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_master(pdev); sp->set_psp_master_device = psp_set_master; sp->get_psp_master_device = psp_get_master; + sp->clear_psp_master_device = psp_clear_master; ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48)); if (ret) {