Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp656004ybt; Mon, 6 Jul 2020 19:32:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw3pQxrBQMkCK1lwvW/akutQhbFvF5m0/1wAhjfVhPDhgt1oBK9MtPD+TFE3/XN4mYt+kd X-Received: by 2002:a17:907:20d1:: with SMTP id qq17mr46503807ejb.214.1594089167395; Mon, 06 Jul 2020 19:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594089167; cv=none; d=google.com; s=arc-20160816; b=tH1LxdNtql2y9jUQvaTczwvRsmOJ5qla7Si6hI/eMdECOHoNZsWGVrb3REzmC7EcLh N/r6svSxnQ1aUGF/mT/XB+05DDRRM/Xw5wnTHPL5KcUV8MceLHQjTazzEFrlSnkThXrf LxkRwIrI9ZtWpF/Pd5uZZq7oUneP3Uc1lH+bWj8sxopmP7qgzETgXJ9ux+yv2zq+18uR 5WHKHk+lm7Y2UJeOtNDM4SD4SUc823KwHTjgsArcvQ26sglyt3TRCL1SB0YackSSNIOs Bn9AqRlJoVgfV1YVQK2RK+T3vuTyWoalpg7L7hMXjULd1Mb889NmrigyV5GW20JGISse jRMQ== 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; bh=6BCYuNjGV5V+54Bo37eKWtHdlaEvn4VJTI41ZOxy2GY=; b=x3JkRLC/g9HIwOxpD6+jVJEloeOs31aWwrrUnLD8AeQP/lC63yvot7BCs3JulJQsmY KmWBgLDc7eNPrQfgdaDZw6SczQnocop2QdQ2lyowK4Q5Lu6N7OOKLBMoRP4MF0bnmjlV 2g/+c9Xg7ULtdfIIVDOdkKimcRnrD7nPtrTeWIIODWLIb1k698SaFxrIPZaDRdAPlCi3 ZdXIGcUcypLsRtUvQIYvmalsGeh8cD3jq8vvRV0XyFrHyyvLlauanCjrFRhCwlxxN4aX FKMscNek3ik3ng9VqsHVBfGDm0alhtuGvgSX1uty0BpjDugnun1rRxRVe9gVvEgFzG/A OevQ== 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v16si14641906edr.93.2020.07.06.19.32.24; Mon, 06 Jul 2020 19:32:47 -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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbgGGCbz (ORCPT + 99 others); Mon, 6 Jul 2020 22:31:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbgGGCby (ORCPT ); Mon, 6 Jul 2020 22:31:54 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CBAC061755 for ; Mon, 6 Jul 2020 19:31:54 -0700 (PDT) Received: from kevin (unknown [IPv6:2600:1700:4540:6a60::14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: alyssa) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 5FE532A4B80; Tue, 7 Jul 2020 03:31:51 +0100 (BST) Date: Mon, 6 Jul 2020 22:31:47 -0400 From: Alyssa Rosenzweig To: Navid Emamdoost Cc: Rob Herring , Tomeu Vizoso , Steven Price , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, emamd001@umn.edu, wu000273@umn.edu, kjlu@umn.edu, mccamant@cs.umn.edu Subject: Re: [PATCH] drm/panfrost: perfcnt: fix ref count leak in panfrost_perfcnt_enable_locked Message-ID: <20200707023147.GB16527@kevin> References: <20200614063619.44944-1-navid.emamdoost@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200614063619.44944-1-navid.emamdoost@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Acked-by: Alyssa Rosenzweig On Sun, Jun 14, 2020 at 01:36:19AM -0500, Navid Emamdoost wrote: > in panfrost_perfcnt_enable_locked, pm_runtime_get_sync is called which > increments the counter even in case of failure, leading to incorrect > ref count. In case of failure, decrement the ref count before returning. > > Signed-off-by: Navid Emamdoost > --- > drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > index 6913578d5aa7..92c64b20eb29 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > @@ -83,11 +83,13 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev, > > ret = pm_runtime_get_sync(pfdev->dev); > if (ret < 0) > - return ret; > + goto err_put_pm; > > bo = drm_gem_shmem_create(pfdev->ddev, perfcnt->bosize); > - if (IS_ERR(bo)) > - return PTR_ERR(bo); > + if (IS_ERR(bo)) { > + ret = PTR_ERR(bo); > + goto err_put_pm; > + } > > /* Map the perfcnt buf in the address space attached to file_priv. */ > ret = panfrost_gem_open(&bo->base, file_priv); > @@ -168,6 +170,8 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev, > panfrost_gem_close(&bo->base, file_priv); > err_put_bo: > drm_gem_object_put_unlocked(&bo->base); > +err_put_pm: > + pm_runtime_put(pfdev->dev); > return ret; > } > > -- > 2.17.1 >