From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B09E6C433E0 for ; Sun, 14 Jun 2020 13:47:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81A8F20714 for ; Sun, 14 Jun 2020 13:47:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AC10VTLS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81A8F20714 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FD6D89E41; Sun, 14 Jun 2020 13:47:21 +0000 (UTC) Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CF1289E41 for ; Sun, 14 Jun 2020 13:47:19 +0000 (UTC) Received: from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 580AFF9; Sun, 14 Jun 2020 15:47:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1592142437; bh=78M8/Iqg3S3zq/AYzhpfmb4A0g++NPy6J82ruz/ctlk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AC10VTLShWRiPx1ZaBkblj33hHeMqBK2vUYAS/uOxQW9wkYL/5Dv7/ssN/BqJQu7c 6zK9jfCUqAHe3ByXr31lHTmFQPcf2SbvwrLn08Hc2fetelZJrZ8UsLIJ3W3/eozyqo dEQ/mOKPq7ZIXAgBOZs33tKtudg/Pi0sWHhKSavo= Date: Sun, 14 Jun 2020 16:46:55 +0300 From: Laurent Pinchart To: Aditya Pakki Subject: Re: [PATCH] drm/bridge: fix reference count leaks due to pm_runtime_get_sync() Message-ID: <20200614134655.GA5960@pendragon.ideasonboard.com> References: <20200614024005.125578-1-pakki001@umn.edu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200614024005.125578-1-pakki001@umn.edu> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jernej Skrabec , Jonas Karlman , David Airlie , Neil Armstrong , kjlu@umn.edu, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Andrzej Hajda , wu000273@umn.edu, "Rafael J. Wysocki" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Aditya, (CC'ing Rafael) Thank you for the patch. On Sat, Jun 13, 2020 at 09:40:05PM -0500, Aditya Pakki wrote: > On calling pm_runtime_get_sync() the reference count of the device > is incremented. In case of failure, decrement the > reference count before returning the error. > > Signed-off-by: Aditya Pakki I've seen lots of similar patches recently. Instead of mass-patching the drivers this way, shouldn't pm_runtime_get_sync() (and similar functions) decrease the refcount on their failure path ? That would require patching drivers that already handle this issue, but I believe that would cause less churn, and more importantly, avoid the issue once and for good for new code. > --- > drivers/gpu/drm/bridge/cdns-dsi.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c b/drivers/gpu/drm/bridge/cdns-dsi.c > index 69c3892caee5..583cb8547106 100644 > --- a/drivers/gpu/drm/bridge/cdns-dsi.c > +++ b/drivers/gpu/drm/bridge/cdns-dsi.c > @@ -788,8 +788,10 @@ static void cdns_dsi_bridge_enable(struct drm_bridge *bridge) > u32 tmp, reg_wakeup, div; > int nlanes; > > - if (WARN_ON(pm_runtime_get_sync(dsi->base.dev) < 0)) > + if (WARN_ON(pm_runtime_get_sync(dsi->base.dev) < 0)) { > + pm_runtime_put(dsi->base.dev); > return; > + } > > mode = &bridge->encoder->crtc->state->adjusted_mode; > nlanes = output->dev->lanes; > @@ -1028,8 +1030,10 @@ static ssize_t cdns_dsi_transfer(struct mipi_dsi_host *host, > int ret, i, tx_len, rx_len; > > ret = pm_runtime_get_sync(host->dev); > - if (ret < 0) > + if (ret < 0) { > + pm_runtime_put(host->dev); > return ret; > + } > > cdns_dsi_init_link(dsi); > -- Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel