Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1215074pxx; Tue, 27 Oct 2020 10:54:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcUDDwDm8l4l4x1p9rDpxAI/TFTXTV898g+QK5pIfNsx3badXPrLMp9g6qL6oTWOeG+fQd X-Received: by 2002:a17:907:a9c:: with SMTP id by28mr3447705ejc.62.1603821283628; Tue, 27 Oct 2020 10:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603821283; cv=none; d=google.com; s=arc-20160816; b=UpDT7B4TaQkeKYoQCxvh3Sqei07Ni+Oj4URX79dJK+3Jf5Jd3FP1b8zu57TsYGB/x+ BGzbAI1IWH2qo3Hdy/DrGwdRqYWShizj1QpYcwiuvVIjTfdmI9E1PzAGS+v3/ttwxdnh iSrFK81tSnN4I1oVcfLoXrM/RfXLPCmG90L0lP88N2CWJqGToR42eMEOW6FUVwrDzxhp kPeJuHt9ycwDYZUSu1sruOnop4Gj+rYDPVcXlA5/o4pfERaaGxGgrCDlIqIk0IOSQW/R UMTev1aMlp24a8WOOJCoOwEFosT9p0uDzuZgeFi35gIqcehP1QLZzBHayy7VfK60SW0D GXGA== 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=efVG501rD8fEeVakKpp9sXAomJcN4CB8cpHPhC3LpyQ=; b=zVrOTrSSlsQgCQJR7gs9fp55LLIdStmTFw2SUpPFRSCrU4r1U9Veh6QbZMGNEtEDTk 2DI55qImwVOBi4W+Qf6NVOjyiFj4GOJssL29Bzp1bWoAt8Dn5ssswTshKmE2g7CZB73x 9eMI21tr3oa5nOoy1KLN1MhfIQFTDcb4dR7Xeu3xW1apWi78poDXxAREFl8QffAvERaM g1WE5HFApOQU9mYgoeRttX2G7aw8v36FyM+n2qO5GYgm3qlDsm1cpdDMrVYCNnhw7Fz/ IZRnlyhi6bPVmHkspKvNqk+UC8Ysj4przmY4WgkFQYFlyricTBM+2IOcgAYEZRei2E98 89hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s59HpwC+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si1390269edq.89.2020.10.27.10.54.21; Tue, 27 Oct 2020 10:54:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s59HpwC+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1818821AbgJ0RXx (ORCPT + 99 others); Tue, 27 Oct 2020 13:23:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:54816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2900801AbgJ0OyZ (ORCPT ); Tue, 27 Oct 2020 10:54:25 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 D5C4420679; Tue, 27 Oct 2020 14:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810465; bh=9wKS+bOD5X6wF0z12+Q03h5eBqJKEhOTM9h6X8XjQEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s59HpwC+lCfOQY5Lbeuq3S613qbIhu0fdM8J1JohyN3UhFfxcpG78nfc+7bT0Hrrn pFOFECVgzl9JpczYk/rJ4mrT6Lt2LeapPoo74VkNesIe2VqN99PkzuSgSNqrhq1jWz v6RbZKMUtaplYbR8e3bXAlupmQAPVWYDitwV0S4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Herbert Xu , Sasha Levin Subject: [PATCH 5.8 108/633] crypto: ccree - fix runtime PM imbalance on error Date: Tue, 27 Oct 2020 14:47:31 +0100 Message-Id: <20201027135527.748297461@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: dinghao.liu@zju.edu.cn [ Upstream commit b7b57a5643c2ae45afe6aa5e73363b553cacd14b ] pm_runtime_get_sync() increments the runtime PM usage counter even when it returns an error code. However, users of cc_pm_get(), a direct wrapper of pm_runtime_get_sync(), assume that PM usage counter will not change on error. Thus a pairing decrement is needed on the error handling path to keep the counter balanced. Fixes: 8c7849a30255c ("crypto: ccree - simplify Runtime PM handling") Signed-off-by: Dinghao Liu Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/ccree/cc_pm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c index d39e1664fc7ed..3c65bf070c908 100644 --- a/drivers/crypto/ccree/cc_pm.c +++ b/drivers/crypto/ccree/cc_pm.c @@ -65,8 +65,12 @@ const struct dev_pm_ops ccree_pm = { int cc_pm_get(struct device *dev) { int rc = pm_runtime_get_sync(dev); + if (rc < 0) { + pm_runtime_put_noidle(dev); + return rc; + } - return (rc == 1 ? 0 : rc); + return 0; } void cc_pm_put_suspend(struct device *dev) -- 2.25.1