Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1022600ybe; Wed, 4 Sep 2019 11:16:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzN6DbTcrtX90Pkli9IOaE8SILEm0uAe+r8S1i+vZw9Psi4b9oZ9PmX6LNM7CtrCv7Q99FI X-Received: by 2002:aa7:8bcc:: with SMTP id s12mr32413203pfd.93.1567621016074; Wed, 04 Sep 2019 11:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567621016; cv=none; d=google.com; s=arc-20160816; b=jqSLu1UkxmD/Hw97L2J5hD0JQkfPgze2M79rYNbJicHbX2Z21Y7/AbTNNAipQ/Pll8 U8gmtrOoKIfIFqhE4PBzrOBGwipvJ0/oAiuKkyDdtRx39565/pPnlAldrpt7yeBlVBO6 pnHqXptrcNfizXpRzbcfLy+U2oPAMCErQAgr2g2Ky0VmdWWC84xJCPIQT5x2HiqjWFpe 4b2RJ/5NQBy0PT0L3SV3kc/rZDEjGpgoG/IL3cJbeycCtOlmRuGEhr2GLjv8C5DjZlIK I9S08Y//vh/3hRG7NyIuHdbLuTa/v10YG5GHd8HwX6t3R987sO0KtvcqASqPfAM6lhKL d0fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f0jmDS7iplshXmwNenK0wrQT24crLjEOZvbJRoFGnyY=; b=P5nsJ4qeuHXbPIJX+lGZCCZEijsbP8fums0eqhGGEqHy0hPH2lk8o04q2AvOXr8c/r aKQ5VB1ur15/xLw4EgNr+ifqi9CH/8IyVa1ANINN8JJUAgbDY6X5oGDSjRvgbfg/wA5Z I48VlK8zOPoZ5hq6c7VakiE4qBnFPyj58K5arCxjpgmunBiUK78zcyjPYyc2uH3m0mkC yLSj6Mvux3x/RJNuSzZ+HZN1L0mdWJ9DcXhkBYXvRPgiaVicf2x7PIomWw8E2AHGKb8Z q5D8oZQ0rkmgg6cquxR7TXdO5Uj4CYfkpNXRlR/4KrKuw8baKayGjfjY7OP9vrP3qHpg GD/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vZH+OapS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x130si17774740pgx.526.2019.09.04.11.16.40; Wed, 04 Sep 2019 11:16:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vZH+OapS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390489AbfIDSOJ (ORCPT + 99 others); Wed, 4 Sep 2019 14:14:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:59174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390193AbfIDSOH (ORCPT ); Wed, 4 Sep 2019 14:14:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C49E206BA; Wed, 4 Sep 2019 18:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620846; bh=AijjDcw+bDNa2gdFvNVN9OG3Ed0uGHSfKxuUEJK5c9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZH+OapStm/CKo2eQrYaS56zs1nQU2fIrRVqsxNwuXuvk1tqorVuhTNT+7l4mVNFO LCfVA7DPRVQxFfu2La8yuu/mbZUhkcr3oQ0gSwUn6f+6XywaxrZLCZQ46OOyHIszaj YtoB0lpsoXwtdmz5AlEMPzKdL3+kYMr0mSzL9UGE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gary R Hook , Herbert Xu Subject: [PATCH 5.2 118/143] crypto: ccp - Ignore unconfigured CCP device on suspend/resume Date: Wed, 4 Sep 2019 19:54:21 +0200 Message-Id: <20190904175319.015719586@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gary R Hook commit 5871cd93692c8071fb9358daccb715b5081316ac upstream. If a CCP is unconfigured (e.g. there are no available queues) then there will be no data structures allocated for the device. Thus, we must check for validity of a pointer before trying to access structure members. Fixes: 720419f01832f ("crypto: ccp - Introduce the AMD Secure Processor device") Cc: Signed-off-by: Gary R Hook Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccp/ccp-dev.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -540,6 +540,10 @@ int ccp_dev_suspend(struct sp_device *sp unsigned long flags; unsigned int i; + /* If there's no device there's nothing to do */ + if (!ccp) + return 0; + spin_lock_irqsave(&ccp->cmd_lock, flags); ccp->suspending = 1; @@ -564,6 +568,10 @@ int ccp_dev_resume(struct sp_device *sp) unsigned long flags; unsigned int i; + /* If there's no device there's nothing to do */ + if (!ccp) + return 0; + spin_lock_irqsave(&ccp->cmd_lock, flags); ccp->suspending = 0;