Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3918653pxv; Mon, 28 Jun 2021 16:38:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEUyW6cwfskcCgFBvjEYz/VALLYprfufSBgHSt+OoVilUDxLFS+9McHiM+agTYQ+QkqV0z X-Received: by 2002:a02:aa8b:: with SMTP id u11mr480439jai.133.1624923538320; Mon, 28 Jun 2021 16:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624923538; cv=none; d=google.com; s=arc-20160816; b=iUo7y3a/Z+leYXqRgUhCHHHJaz2JLncuV5SJUDrMxY13O5Su05IHhS3e2PfItOsLMv uJVS7mWDltqEwI9N/RtaGtZDX83qS5XeZJC1y2rLjJzPLp5dad+RuZ0uPP8rA50MZemY Mwlb/FmMClbavyam9afWX/WkklXxqtpEJhyeINeAelhginw+riXSgbkCKNZvo58+cUtX P4jTYw96aFius7JTHNsYNUW8t03wBSpNrk49iLegWImfF+HmfVy+w8+vTMc/06RMB/MI 2e9cWS2MWT+9RVJCeuzvcdW3Q6yTd3rqF4JyfHo06BscWkpqwJpAXJcrvbkGdCIV2LhW Je3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=A2ZbbDOrobAxZ2RbnCqZ4KqUv7S/EmCV9Jru/9Q6gGg=; b=JAgpQ4Fr7YvbaOWw01WPL4BcINNOr0FbMtRBv1KOOYe7fR7yG99R0t4DmEv1cBcNHa XWp8KSzYCnenk7YafGlZCLxBJrMrhSmQ7gfbf3Zx7JTnIFrbdStdwWqo8wSo/H0smKhp ceQLvkwGfAN6T4L4Mxx0hT65hfxGqBK1LgudjeCIQ3Y+21K/M7A80jl86io3bcnDyvjC 734Vm+2SkqX++Y//Qpka/3VAMjeOonoZOrQfv18CilnsItTAy8ftTx2QzTZQlkxWD00A rTICQYjSjg8W+RVlkHpsganMsPTLoIbgELzw5jEQYbfRgWJM/H8I/Fw3UvEfEaJYTu99 8pRA== 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 a1si18326448ioe.96.2021.06.28.16.38.46; Mon, 28 Jun 2021 16:38:58 -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 S232227AbhF1RDm (ORCPT + 99 others); Mon, 28 Jun 2021 13:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232186AbhF1RDk (ORCPT ); Mon, 28 Jun 2021 13:03:40 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9872AC061766 for ; Mon, 28 Jun 2021 10:01:14 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lxud9-0001ns-TS; Mon, 28 Jun 2021 19:01:07 +0200 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lxud7-0001Xx-7Z; Mon, 28 Jun 2021 19:01:05 +0200 Date: Mon, 28 Jun 2021 19:01:05 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Zou Wei Cc: Thierry Reding , Lee Jones , Linux PWM List , Linux Kernel Mailing List , "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Linux PM , "Rafael J. Wysocki" Subject: Re: [PATCH -next] pwm: img: Fix PM reference leak in img_pwm_enable() Message-ID: <20210628170105.apt7numxkdyxf6q5@pengutronix.de> References: <1620791837-16138-1-git-send-email-zou_wei@huawei.com> <20210512045222.2yjm6yxikznohlmn@pengutronix.de> <20210628063839.5oeh5fvvoy3fk2gw@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="6vc24ibvllo3lf7c" Content-Disposition: inline In-Reply-To: <20210628063839.5oeh5fvvoy3fk2gw@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --6vc24ibvllo3lf7c Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Zou, On Mon, Jun 28, 2021 at 08:38:39AM +0200, Uwe Kleine-K=F6nig wrote: > On Fri, Jun 25, 2021 at 07:45:14PM +0200, Rafael J. Wysocki wrote: > > On Wed, May 12, 2021 at 6:52 AM Uwe Kleine-K=F6nig > > wrote: > > > On Wed, May 12, 2021 at 11:57:17AM +0800, Zou Wei wrote: > > > > 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. > > > > > > > > Reported-by: Hulk Robot > > > > Signed-off-by: Zou Wei > > > > --- > > > > drivers/pwm/pwm-img.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c > > > > index cc37054..11b16ec 100644 > > > > --- a/drivers/pwm/pwm-img.c > > > > +++ b/drivers/pwm/pwm-img.c > > > > @@ -156,7 +156,7 @@ static int img_pwm_enable(struct pwm_chip *chip= , struct pwm_device *pwm) > > > > struct img_pwm_chip *pwm_chip =3D to_img_pwm_chip(chip); > > > > int ret; > > > > > > > > - ret =3D pm_runtime_get_sync(chip->dev); > > > > + ret =3D pm_runtime_resume_and_get(chip->dev); > > > > if (ret < 0) > > > > return ret; > > > > > > This patch looks right with my limited understanding of pm_runtime. A > > > similar issue in this driver was fixed in commit > > > > > > ca162ce98110 ("pwm: img: Call pm_runtime_put() in pm_runtime_= get_sync() failed case") > > > > > > where (even though the commit log talks about pm_runtime_put()) a call > > > to pm_runtime_put_autosuspend() was added in the error path. > > > > > > I added the PM guys to Cc, maybe they can advise about the right thing > > > to do here. Does it make sense to use the same idiom in both > > > img_pwm_enable() and img_pwm_config()? > >=20 > > I think so. > >=20 > > And calling pm_runtime_put_autosuspend() in the img_pwm_enable() error > > path would work too. >=20 > Do you care to clean this up accordingly and send a new patch? Note that Thierry applied your initial patch regardless of the inconsistency. Still I'd like to see this done in a consistent way. Do you care to follow up with a patch that unifies the behaviour? Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --6vc24ibvllo3lf7c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmDaAEgACgkQwfwUeK3K 7AlUoAf/TOnUhoj0eYiWSFbUFIcG0bz/eWla1yA5dXRk4X4sRIy/dWLm4jwE0ti6 lDWAa//MvhSa6cjZRiqr8MUvxjfwCkfG6C8HAt59seEhIlLOM9xZDkIuh2mrig9Q AUgCjwqqghPf5anR7IVWAQf+/ezprH1q7Jn/IFwrnQIlR0eI5Hd6Mn7axAqDC/xQ mhbj/vxJOqHzYlSwg760PL3AL1PL2hwAiZgnjId9qz3w/JMZECKCjqTuKTF0ZvkG gDQR+jpY9ouPM2Tn/aFLxAePAjsP/Pkhhzgo8j2NsE6x83tiBFwqrTfDQHsEr6cd xx9orGAcN0UFeY17YNsAuCNUDSUlOA== =y4Gg -----END PGP SIGNATURE----- --6vc24ibvllo3lf7c--