Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4045069pxv; Mon, 28 Jun 2021 20:27:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5zcExVi7gZCMFkj8qZqW8pn3tOSQgceXtOyAp/lzAdiwM3/Bqa6pCUXKjKLGzMpV4jGSb X-Received: by 2002:a05:6402:4cf:: with SMTP id n15mr38527212edw.162.1624937228687; Mon, 28 Jun 2021 20:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624937228; cv=none; d=google.com; s=arc-20160816; b=q3MYsmPG/QG09az3jqgvkPjEx5DNyhl79ycpb8/Eqa2JBQKnyVoIcB2wb6ATR2hAGN p8Jvskpq85jmfdkXSXFpwLVmD+cTUF5IWEbTAO+XEX6b0pR3Vv3iiVxos9O7qgeFWQo6 VCerpe0xdT9juTATDQOO9CiFnHG80Cu3jG1j0cF9XlZ1ruT6XSAqQdEL1HJgwTuZkRNn boDZAt+uaYMVzcfl1XoyKpKTm3LYScpQ57Nx89eltQhr2xFKUKusGfWuGQg9M54Yy0a3 btS9oiaXF18ebmP/l3+V52ANuoYpO+Gv5Ec73ii7voHyhlWQpsVOshZwABKaj8pMapmf L2HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=DCVLosi64/16jeGsDzvYC1aBhodlP8DKNsv1Aoixu6w=; b=yGAJufQD2tCdvOxLZCnDAyLwMb+URdk3rx2EhHLIp4Mn2iqal18q4VWb8JOziBgi6M 15D/TT06CUr5P50qd+P23G4z4E/IvrElY6JGwwftfTv8TiSlKHZLiaci0vAqHfq55s/h DRXrNeWu4VBGs+hfFZLJ21tLmli2hcIbB8AstK8rRRn08EVNrgpXiSOzahITn8ckHhtX R516yTsgnj0lWTZ/x0u8+AZVutDUuhI1czv34OttnXsudR1WqsgeOaAIoZKTs6dx/zmS 8atXCnZsWiGGQh2kDIUOx8oFwfCysV/oQiYrPsMf/TohPb6A1k35aFcHwhQ1b6G0nWEe r+YQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci11si9427092ejc.28.2021.06.28.20.26.43; Mon, 28 Jun 2021 20:27:08 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231864AbhF2D0N (ORCPT + 99 others); Mon, 28 Jun 2021 23:26:13 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:9296 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbhF2D0L (ORCPT ); Mon, 28 Jun 2021 23:26:11 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4GDV6m6xVvz1BSbD; Tue, 29 Jun 2021 11:18:24 +0800 (CST) Received: from dggemi762-chm.china.huawei.com (10.1.198.148) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Tue, 29 Jun 2021 11:23:42 +0800 Received: from [10.174.178.208] (10.174.178.208) by dggemi762-chm.china.huawei.com (10.1.198.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 29 Jun 2021 11:23:42 +0800 Subject: Re: [PATCH -next] pwm: img: Fix PM reference leak in img_pwm_enable() To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= CC: Thierry Reding , Lee Jones , Linux PWM List , "Linux Kernel Mailing List" , "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Linux PM , "Rafael J. Wysocki" References: <1620791837-16138-1-git-send-email-zou_wei@huawei.com> <20210512045222.2yjm6yxikznohlmn@pengutronix.de> <20210628063839.5oeh5fvvoy3fk2gw@pengutronix.de> <20210628170105.apt7numxkdyxf6q5@pengutronix.de> From: Samuel Zou Message-ID: <060df682-1490-be4d-ff84-5e05cbdd9101@huawei.com> Date: Tue, 29 Jun 2021 11:23:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20210628170105.apt7numxkdyxf6q5@pengutronix.de> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.208] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggemi762-chm.china.huawei.com (10.1.198.148) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Uwe, Sorry for the delayed reply. Thanks for all the review,. To keep the consistency, it's better to clean this up accordingly, and I will send a new patch soon. On 2021/6/29 1:01, Uwe Kleine-K?nig wrote: > Hello Zou, > On Mon, Jun 28, 2021 at 08:38:39AM +0200, Uwe Kleine-K?nig 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?nig >>> 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 = to_img_pwm_chip(chip); >>>>> int ret; >>>>> >>>>> - ret = pm_runtime_get_sync(chip->dev); >>>>> + ret = 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()? >>> >>> I think so. >>> >>> And calling pm_runtime_put_autosuspend() in the img_pwm_enable() error >>> path would work too. >> >> 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 >