Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3068972pxj; Mon, 7 Jun 2021 01:08:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycSAB6kmcGjit6vy+MoulM3YjP5SnVcKziqj6q78W3Loayz49rjlLB4pmBv8GYWcrz5eVP X-Received: by 2002:a17:906:3ed0:: with SMTP id d16mr16557164ejj.16.1623053324863; Mon, 07 Jun 2021 01:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623053324; cv=none; d=google.com; s=arc-20160816; b=oMWO4A0TrMPe6SVEbCrRzJ4qXByB5g1/fieYqzoL2AWwcG8MucKxHXQLkHek1+HJ6t B5Lpwkg6LFGxSLqd2NeTaW7bsbMMX8zsjFKTCYBnGvLwPKdSa20Q2xBCMpmsf5HHdDTn vcIGCCix2UpvH7HwPW2QBPapjjmmsP+RACPm+69wxUNpujji9hdYXV9tb5dQu4DrCQ4k fNrLDpH9Md0XMEYSmNkuTB9byoNDzlEvQQJ37DHwskSSFG0Z3Ycb9xxe81ItD4N0n5Ob 6hq9ZfcPRKQRWq10CoJKaNMFGHrfDgWuQQmMSkH3XAcaSFK5mo1Cjwwp6lX0FuzKGpV1 q0Aw== 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:dkim-signature; bh=Sdz3ye23TVZRNEUMW2su9w2lliR3WU/2PvKXvgOU8R4=; b=GuVXqiO1hYMhe1lq/svmGQngcjHUe0iCeTH7/7Fs60iHdNFc3aQGtyGSljPbLpK+dc aJXGv7uOobcHYB1jP8mlPPIjJvW7EaXN2Jft5jSYSyPx+BEyx4dhDSLUEngMbTyexXHw dDDBA8Cq9ONQlCi/WlHYDq+YcYz8muFmAF8hPV4gKx2faIlvlGP+9tIo/OXogipbLJEN SivhQhBRjw1iK8nGiRShUZ2Ih8ygnLBu32VreG8vd++17pg2zWsDKvUyIjUmVNMsM6Rw 0zpIExOddhsG4P+jVxW0OMRl9fhpJfoKnEuiN35lmF12p5IGPCUV3I1NjjMfhE1bX5hs dIOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sM2u+Wyf; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt8si11301348ejb.622.2021.06.07.01.08.21; Mon, 07 Jun 2021 01:08:44 -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=@kernel.org header.s=k20201202 header.b=sM2u+Wyf; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbhFGIIp (ORCPT + 99 others); Mon, 7 Jun 2021 04:08:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:59196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbhFGIIn (ORCPT ); Mon, 7 Jun 2021 04:08:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5849D6102A; Mon, 7 Jun 2021 08:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623053212; bh=xmIDJ297EbDzxkQF9obeTuoyIAjOCtz2+6Ofw+DrFXA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sM2u+WyfdldAkzzqhNEq2wVbktPE9gknkrkYPnr8/LdjYaKYBXHFiOr+U8NylodnI dKCe3oCN2qVP2hFpiTEofcH0Pq0cCumErxKYvFsJMlgjmNMABEE2OdTPsV2zfG8KZA r5hy6REuclAD4YTFgHZlkFFt2VpdPNzwM6wsdtfajESdm8taI/7o37jA+65CEvmp8y Y3SfrV4VpNVsJttuF/Fu93gt+mfN10rkDCg+YM1BV5Jho1oqoDXosVqcXuQ8HBmBhR 6+O4rcp61F7naUFa5GLuo6zPA7M0I7iKcn8mc/jVvLmTPOnFU7sAaFhRo+eFqHvdpZ hLfIiy8HB0bGg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1lqAHU-0004Ne-KD; Mon, 07 Jun 2021 10:06:45 +0200 Date: Mon, 7 Jun 2021 10:06:44 +0200 From: Johan Hovold To: Vinod Koul Cc: "yukuai (C)" , mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, michal.simek@xilinx.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, yi.zhang@huawei.com Subject: Re: [PATCH 2/3] dmaengine: usb-dmac: Fix PM reference leak in usb_dmac_probe() Message-ID: References: <20210517081826.1564698-1-yukuai3@huawei.com> <20210517081826.1564698-3-yukuai3@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 03, 2021 at 04:39:08PM +0530, Vinod Koul wrote: > On 31-05-21, 11:19, Johan Hovold wrote: > > On Mon, May 31, 2021 at 02:27:34PM +0530, Vinod Koul wrote: > > > On 31-05-21, 14:11, yukuai (C) wrote: > > > > On 2021/05/31 12:00, Vinod Koul wrote: > > > > > On 17-05-21, 16:18, Yu Kuai 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. > > > Yes the rumtime_pm is disabled on failure here and the count would have > > > no consequence... > > > > You should still balance the PM usage counter as it isn't reset for > > example when reloading the driver. > > Should I driver trust that on load PM usage counter is balanced and not > to be reset..? Not sure what you're asking here. But a driver should never leave the PM usage counter unbalanced. > > Using pm_runtime_resume_and_get() is one way of handling this, but > > alternatively you could also move the error_pm label above the > > pm_runtime_put() in the error path. > > That would be a better way I think Johan