Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2556510pxj; Mon, 10 May 2021 05:52:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlq++BMGor/fPRwHm0LP4LpD3lsSyRHgpK3Fo76ZuwACIDGCO4sekvb/sPZEdyV/zqN6zB X-Received: by 2002:a17:906:1311:: with SMTP id w17mr26516399ejb.182.1620651151095; Mon, 10 May 2021 05:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620651151; cv=none; d=google.com; s=arc-20160816; b=RuxKsM7DvGRR/zsCZBNagcaSADMOfDBboqs4SHruR6anLo/AUVt8FgW6nDrG9f83oQ Rm7/yW5agzhURAWpUwNBgmZW9icWgRwkwvOn/XvA/7YMvL1ErNmxeW/i9SOR8XXYRzPF OLRUUI952eAtx66pbkxYtHB7YUuzJppi9vnv/VTmnvqQHscH8UEbpAEii8EcVm0OWJOy c9X0S4M+XSoEW9P8lvbzBf2F1hR6wV+XADdHguThgXCUzBuGboFgFNaffX7FdtA9XcIQ arpa0pTF485C6ZT80TPz9YUKjENfUlIDgUrVm2YO61i2hPwtHRLAX/34DaqrLfFNgiPk TtTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=uGjRMdOAh0NsalHBxcXwol+/KH6+ZmIOjEdsVEsR1wI=; b=zPPX003cOJKSrbu4ARAozZ+TO6RYpngTDkzzoQwOJ65VMR+r3MelJ+PSJJia7yAVlR PcOC6t/HSgYL3tOpjY7vDyZQ69bfgL7unNsR7Mdv+kA1YGD6h2j7lcI4jSrvPiEifPjK zuBEB5xnUERxQifiMLSfSEW3dvAosPVB/I2zEqwzINTQQ0lXXB/JhYEdT8dPWdNt7tuv QNpUPx1ZplKZ3X8v6W7nR9JCN+XvCNzigSpSWsBKILNeDdmX6NLhPE2eaZO7yMQncmfC twL2qEOAGGpfXEnrGCl9SGTkFjRTRxEPPwZ+qeCzJ4uC6s1l1fkafHKsb/rkXZTP1oet k9zw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si119659eds.334.2021.05.10.05.52.07; Mon, 10 May 2021 05:52:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241783AbhEJMvW (ORCPT + 99 others); Mon, 10 May 2021 08:51:22 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:54664 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234630AbhEJMIs (ORCPT ); Mon, 10 May 2021 08:08:48 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 6848E1C0B7F; Mon, 10 May 2021 14:07:42 +0200 (CEST) Date: Mon, 10 May 2021 14:07:42 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Shixin Liu , Herbert Xu , Sasha Levin Subject: Re: [PATCH 5.10 105/299] crypto: stm32/cryp - Fix PM reference leak on stm32-cryp.c Message-ID: <20210510120742.GC3547@duo.ucw.cz> References: <20210510102004.821838356@linuxfoundation.org> <20210510102008.407819731@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kVXhAStRUZ/+rrGn" Content-Disposition: inline In-Reply-To: <20210510102008.407819731@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --kVXhAStRUZ/+rrGn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon 2021-05-10 12:18:22, Greg Kroah-Hartman wrote: > From: Shixin Liu >=20 > [ Upstream commit 747bf30fd944f02f341b5f3bc7d97a13f2ae2fbe ] >=20 > 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. Yes, but that only works when code checks the return value. > +++ b/drivers/crypto/stm32/stm32-cryp.c > @@ -542,7 +542,7 @@ static int stm32_cryp_hw_init(struct stm32_cryp *cryp) > int ret; > u32 cfg, hw_mode; > =20 > - pm_runtime_get_sync(cryp->dev); > + pm_runtime_resume_and_get(cryp->dev); > =20 > /* Disable interrupt */ > stm32_cryp_write(cryp, CRYP_IMSCR, 0); Again, this is wrong. > @@ -2043,7 +2043,7 @@ static int stm32_cryp_remove(struct platform_device= *pdev) > if (!cryp) > return -ENODEV; > =20 > - ret =3D pm_runtime_get_sync(cryp->dev); > + ret =3D pm_runtime_resume_and_get(cryp->dev); > if (ret < 0) > return ret; > =20 But this may be right. Best regards, Pavel --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --kVXhAStRUZ/+rrGn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCYJkiDgAKCRAw5/Bqldv6 8jAUAJ4sCCOB4Iu67jIwt5xH1DGKnA1rngCeMAdwdlkpwrCsBOHr5fmCHel8j+k= =ZzZU -----END PGP SIGNATURE----- --kVXhAStRUZ/+rrGn--