Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp991713ybt; Sun, 14 Jun 2020 06:50:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8ekQ8gfr4/OF9hLneYRz1kpS9ZAupHwEbGQdsvt7xrDKaf5dZdm11ve2V8xjTJECTmR6Z X-Received: by 2002:a17:906:3447:: with SMTP id d7mr20030161ejb.375.1592142608301; Sun, 14 Jun 2020 06:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592142608; cv=none; d=google.com; s=arc-20160816; b=jhPvfV3/GZBHp+Kv3GOisiEdvNCnfqC2yWm+YYwAnXXzMU4JMlN9a21ZRq5DP1xiAA aIrzpCF7n9Q/CAP2YoSEaidDvrCiCCaCBQlTwUCrqvR3YYHKAOXbucRIH8qi0941zUdl ijA31uI8EcLVVSZ+qPpWfMMC2JOis7yDHgL0VpkyksADC3Xo2w22X0TQdjUYimtpwdxi Y8XSxiOxIlOAYiQSh9I2gBzyNDlw1MYnELDbAth9mM0I1IqykdQGm5VTwiSciWr4pCwh bKYHzX1ri92pgCmweH5KlILI/T5nTSj/rl8naOYLCdTOUirm0rC0me6B9zQ1usSlduso SwNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ig3+A3LSvXXkoX9KUJpLwL77t+tRFsap8lWWAvoElmQ=; b=PzURTlL/Fv3afKGh4QjkoIOa/OUrP+foLuGHk3CWXe0Y+9+CzLewsXhOiHX+eB2XNp e386lVOF3nbSsLuFpu2fqqZT8zazq2EgJ8uLokwp7W6+2CzKZRg2O99obyvGOpYVgync ZsPYsG1VVIdHyKf1CPbDVgDLPBUSqYZThalT9h/sCqXbBWEQGZIjbTO5vs7zGq0NUvKl Qf9r+raluI0AK+KWXRXX4so52uOKoVDA093b1+XiZhHopnP43b6jgjKJrSZJvNx8hWUV YHQsz4Yu2SB5ozFX/gQkZfAS3aL6fxSDknW1VPmcW+ltMiqQqhdcDyUuY048VO2pcLkh aY4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=AC10VTLS; 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 h10si6941651eja.608.2020.06.14.06.49.45; Sun, 14 Jun 2020 06:50: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; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=AC10VTLS; 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 S1727811AbgFNNrY (ORCPT + 99 others); Sun, 14 Jun 2020 09:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbgFNNrX (ORCPT ); Sun, 14 Jun 2020 09:47:23 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6156CC05BD43 for ; Sun, 14 Jun 2020 06:47:23 -0700 (PDT) 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 Cc: kjlu@umn.edu, wu000273@umn.edu, Andrzej Hajda , Neil Armstrong , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" 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-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200614024005.125578-1-pakki001@umn.edu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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