Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2561567pxj; Mon, 10 May 2021 06:00:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1lE8LrbLO0CVhoB376SY1qLZsn4q6qHKDareRy/yTpuzuVN0hx5Dt59ZnZ1kAdDHfQNFL X-Received: by 2002:a17:906:590b:: with SMTP id h11mr25607074ejq.147.1620651601522; Mon, 10 May 2021 06:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620651601; cv=none; d=google.com; s=arc-20160816; b=GfX28xIH+Qj8lB8kOneaNxrVjMaQSuyEzXm6X3Aexy+PMJlWr3lULYdwh3ImHXaW0c ekdET7dugEkpELjK3Q4qKMVwYwq34kzWKtaGZ0yG64LwxYb0v6N+xdqlatprWfkwBOtw XxclkrQ1cQmod5rmhpjYPQwf+QhA3/y2KCWwUA68jV51JYmOdT8QBIhhR+jRxf//UKqW gNFzkXWRvYOCixJz+1rZ82bjYsHqGsGvM8MYT3c56+eR4fEbfigjNg9GWR00z4MHRK7i XzsT/bKY7HN/osObdfwv6FEZ0EMTxvjbnZi37RkllriJ66CunR1pQj+OsmivflATo9Nb BSyg== 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=BWIEFvetKlskTjJcTTEH4BCAfOhpneyC18ymQM7J+oM=; b=GoowoQ9oV+wZ50K2PUDMOKbpO/3ttKOkiDXHiGjXciDFUqLTaKdhj7/VXb2ObLaof9 TcJM3P8aOW+b4CHoGqv3Ks/x+rJlqKr0QHQBUMb0bctw3R6mWOz89T9Y/yedJINIJfrM 6dV5zRDmVXDqrLjRSfTswbE1k82VGo3puAVBXaXX6vMDXtMYVAdsf4b9g3wCpImXTkBm szR+ALMCsEX7/2BX3usiIH/w3Y3i5KgT27cmWxN4rjoWs83RqRPbmLyIC6V9aXEjxe/O y6v79RI4PKlaza4nB7eslfQKv+3aqlaLOVbMN6Ty0F4/zGRq4FB7a8KaIc0jTSkUrwgJ DBAg== 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 q8si13422086ejy.320.2021.05.10.05.59.37; Mon, 10 May 2021 06:00:01 -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 S239308AbhEJMvE (ORCPT + 99 others); Mon, 10 May 2021 08:51:04 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:54446 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbhEJMHF (ORCPT ); Mon, 10 May 2021 08:07:05 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 8E4331C0B7C; Mon, 10 May 2021 14:05:54 +0200 (CEST) Date: Mon, 10 May 2021 14:05:54 +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 104/299] crypto: stm32/hash - Fix PM reference leak on stm32-hash.c Message-ID: <20210510120554.GB3547@duo.ucw.cz> References: <20210510102004.821838356@linuxfoundation.org> <20210510102008.377102138@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="s2ZSL+KKDSLx8OML" Content-Disposition: inline In-Reply-To: <20210510102008.377102138@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --s2ZSL+KKDSLx8OML Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > 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. I believe we need to enforce "patches need to be tested" rule at least against robots. Code was correct in 3/4 instances, this introduces bugs. Yes, last one needs fixing. Best regards, Pavel > +++ b/drivers/crypto/stm32/stm32-hash.c > @@ -812,7 +812,7 @@ static void stm32_hash_finish_req(struct ahash_reques= t *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); > =20 > 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 *re= q, void *out) > u32 *preg; > unsigned int i; > =20 > - pm_runtime_get_sync(hdev->dev); > + pm_runtime_resume_and_get(hdev->dev); > =20 > while ((stm32_hash_read(hdev, HASH_SR) & HASH_SR_BUSY)) > cpu_relax(); > @@ -999,7 +999,7 @@ static int stm32_hash_import(struct ahash_request *re= q, const void *in) > =20 > preg =3D rctx->hw_context; > =20 > - pm_runtime_get_sync(hdev->dev); > + pm_runtime_resume_and_get(hdev->dev); > =20 > stm32_hash_write(hdev, HASH_IMR, *preg++); > stm32_hash_write(hdev, HASH_STR, *preg++); --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --s2ZSL+KKDSLx8OML Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCYJkhogAKCRAw5/Bqldv6 8v/SAKCt0vlNj8WNcw3FsHi/g5drvv9CugCfQnV2lUXyG4V2RpeJ7VBSwT893TI= =oHNw -----END PGP SIGNATURE----- --s2ZSL+KKDSLx8OML--