Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1011083ybe; Wed, 4 Sep 2019 11:06:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0uNnF4CaiKkz78PElmbGVBnNQ9EiQq5haZ/HuTQX7By088bkrfaR9EeNuimxPt9uYOKb4 X-Received: by 2002:aa7:8acb:: with SMTP id b11mr46061176pfd.109.1567620411559; Wed, 04 Sep 2019 11:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620411; cv=none; d=google.com; s=arc-20160816; b=PxvIeLw47nIuH3WtdnEQH7aVJ8DqDX5P+AwYGk4P36SB6kSoqz6/F0bGqtcgwWG5IM lRdUXHla0lh5sngKuBlttK67hr61DBvtdahC1Qld06mvVfu8RZ4Fowtx/Of2kwy5oVRw Pxa6ycyvFSD0jVFHu/uoSXLq1GFjyf472w3z6OvqqOSh7ifkXIiJHmGAwCQJBfBz5Sid xOmiFH/ldc9HWfWZ0uSdR64m490XVCBWRiF0Nka4J+Iz6t/paCKF816KN7TmyILyr45x KIqjQgPxkeNUCARZrol3D2UBMp7OnLhH/F7VA4mGsoHU7JIXrMC+Mz4HblFNaALfq8ay bvlg== 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=sTNX2UZJxpDUfM3xVfsHuM+riDayT5Wh+Idfp9IjsGzE2bDHJ23jbEs461DSMpIoOC SKuLBtgHi7Sbnd9NpT3z5OF02Eham/3gCpi0GifmFdGEiRsE2ELrAfVrkXABjsjdWRsY ez+vi8qHHn1bQK923UbLNS4JIIkS9BgTWwXm2/HqIiPy+2P95zM7959EoggvnCUwPt3j HwPkPmulY1Uj4iCl2z3t3kLgyfpJFgk9penIxalddv8lTNKMuDV86zBLbioeBEiR9EKA hHvuJGpmrygGNspTRDqCzoLWjNGunrModjUPZ8Ru78REgyxRUtGyFjLfik8d2nejn9a1 QLcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0wVdqAer; 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 x185si18026248pgb.161.2019.09.04.11.06.29; Wed, 04 Sep 2019 11:06:51 -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=0wVdqAer; 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 S2389154AbfIDSEv (ORCPT + 99 others); Wed, 4 Sep 2019 14:04:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:45992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389143AbfIDSEt (ORCPT ); Wed, 4 Sep 2019 14:04:49 -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 A3664206BA; Wed, 4 Sep 2019 18:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620289; bh=AijjDcw+bDNa2gdFvNVN9OG3Ed0uGHSfKxuUEJK5c9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0wVdqAerCiuBC+EbDWcklDaqpGzb9jOBICrTEjARWtTV3xpOPB1SeUpEsgRsDo21x d4O/zj4ldgiyYTO8lw+c7MPTbgryIB17EPvekrRRqMFP+rL2z35Zl4cThKKuNJlMvr yjwpl8ssQR+FYoq30bIr9EiIV1pYFnrK/Gu5FULg= 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 4.14 46/57] crypto: ccp - Ignore unconfigured CCP device on suspend/resume Date: Wed, 4 Sep 2019 19:54:14 +0200 Message-Id: <20190904175306.500033868@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175301.777414715@linuxfoundation.org> References: <20190904175301.777414715@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;