Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2477172pxj; Mon, 10 May 2021 04:03:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOzvyG2K/3onXgvW9Ot8OewAHZ8jkx3XZTkNgxf+QNoOhMODzCkYaPCkYRK5fyu0tRs+vo X-Received: by 2002:a05:6e02:1be6:: with SMTP id y6mr10933232ilv.242.1620644623466; Mon, 10 May 2021 04:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644623; cv=none; d=google.com; s=arc-20160816; b=1JXxsJ+D6I4OdWglVEkdiTwYIwfPrQyWr8BsP9VnJdN8cy3fBrUxFiuZ47y2BtJJKY 2joY+RTS7nAWvZCrXP/DF1n2BBnGDMDqYXIxImWuV8LTJKExQYAijGLjn9hDVey5yg1W LVEXmZoAwysoAmp4hVfwA6pVnmiwY77e1d7ZlsB+7dmubqsqKgwWXb/1sSrzXEH+OlYE sJa3TbMPUxMkOfVBmHv6EhaiuIqjgtE8Zi/SfvTOvw/0LUTKgL/xs8qJqP2cHaCpbobe 3vQ+FzhqWVoynrCc8O3tlXktrCRV8zcwcIilnMV6jy4448W2qffVN8EoReJlJxwKL8TY lwaw== 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=jrOhsaEq4TpPMjR64noOoS+oIrFiAu5X9nPVc/49aP8=; b=SO7H57Zn+ysu3TXdnhqBc6wpAXLlaRSXv02M/hHoEumTJJ8bBOFNeMh/K3eBHrlHfk hb23qCHAspg09Z5ebAhpYtV2lJDwrqKsuv7GpynLggpSdzk6ZAWA2VJe2qriHXPLTSDH GDwfq2Pb8+P28WjDcQoB9Xr36MAqxZZT1IY4IqCLz9urkx/wrg3TdUk+xvjBsjhAByh5 Chj+UzIRLLnwVC+681pqChX2+w2GMoxodN5e2dbg0xVjqy22pd9DwY1XsY0jgYck3VTz zx+7Ts5UyIwuOVxC5TbsAIaK/s/hR5Vol4Cjv/et9UkemcpmGSQz+WjC7Xuhw3NB2t+D VxRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OWUOTF29; 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=pass (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 w5si17529407iov.91.2021.05.10.04.03.30; Mon, 10 May 2021 04:03: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=@linuxfoundation.org header.s=korg header.b=OWUOTF29; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235293AbhEJLAh (ORCPT + 99 others); Mon, 10 May 2021 07:00:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:59672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233190AbhEJKpR (ORCPT ); Mon, 10 May 2021 06:45:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 18B356192B; Mon, 10 May 2021 10:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642916; bh=wz0SMAT4dCwBE+xhP1dOXkn4JyERS/IU/3JwEWW4vr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OWUOTF298yYxloy43Qv2tMfXRMKHOVp9Wmh8a8NGnOfKARf9MFVSEO38wp+6zuiuc j6DUbIEE4xHlFiLSDNut7qvELo7xkaU/z+UpDj2k+6WxmNzgYZC8vBr4UNWnuG6yaj DV6AGvOryDWLJm/kValpIdQf6VAACbRPsTSimQrI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shixin Liu , Herbert Xu , Sasha Levin Subject: [PATCH 5.10 104/299] crypto: stm32/hash - Fix PM reference leak on stm32-hash.c Date: Mon, 10 May 2021 12:18:21 +0200 Message-Id: <20210510102008.377102138@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Shixin Liu [ Upstream commit 1cb3ad701970e68f18a9e5d090baf2b1b703d729 ] pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. Fix it by replacing it with pm_runtime_resume_and_get to keep usage counter balanced. Signed-off-by: Shixin Liu Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/stm32/stm32-hash.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index e3e25278a970..ff5362da118d 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -812,7 +812,7 @@ static void stm32_hash_finish_req(struct ahash_request *req, int err) static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, struct stm32_hash_request_ctx *rctx) { - pm_runtime_get_sync(hdev->dev); + pm_runtime_resume_and_get(hdev->dev); if (!(HASH_FLAGS_INIT & hdev->flags)) { stm32_hash_write(hdev, HASH_CR, HASH_CR_INIT); @@ -961,7 +961,7 @@ static int stm32_hash_export(struct ahash_request *req, void *out) u32 *preg; unsigned int i; - pm_runtime_get_sync(hdev->dev); + pm_runtime_resume_and_get(hdev->dev); while ((stm32_hash_read(hdev, HASH_SR) & HASH_SR_BUSY)) cpu_relax(); @@ -999,7 +999,7 @@ static int stm32_hash_import(struct ahash_request *req, const void *in) preg = rctx->hw_context; - pm_runtime_get_sync(hdev->dev); + pm_runtime_resume_and_get(hdev->dev); stm32_hash_write(hdev, HASH_IMR, *preg++); stm32_hash_write(hdev, HASH_STR, *preg++); @@ -1565,7 +1565,7 @@ static int stm32_hash_remove(struct platform_device *pdev) if (!hdev) return -ENODEV; - ret = pm_runtime_get_sync(hdev->dev); + ret = pm_runtime_resume_and_get(hdev->dev); if (ret < 0) return ret; -- 2.30.2