Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1515047ybt; Thu, 9 Jul 2020 08:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtgQVs0Z3VIAXx8HMMSsWzx7zSFAYNvuzAwyeOCQbly8xeweljY7TAj/OSecO+u1oizH/Q X-Received: by 2002:a05:6402:947:: with SMTP id h7mr72876170edz.213.1594309731330; Thu, 09 Jul 2020 08:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594309731; cv=none; d=google.com; s=arc-20160816; b=DEO47DdYZDGGrzI0IQfijONOoBIcx/AIYjDhiCPFjwNH9d/Ny+/4cakPdrWXvg+1yL 3YBdOfPUUYD6/RYARusPF4MfyiKV27AajWpUF26nQBz+EvEzSsFV5BXskcElnqE51Ifk +iopyGFIYjMXcLuQJSLXhjrDkhFhkuFo2rw0Ds2ywIw9CEAtYW3Tn1kSOG894vQz3n/P V8d8AQ9RNaJbWXBJAdIRh4H0RytSGh2+hYljyP4L+MTwfegEHN/JmsZtVAs3STQmMcZP UHValQ0aLsPKkBedr/Xnu88IR19KSFPx27xhTHCZyZPHgirpNMlPSfvoroEsUy4SdfQQ GtzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8orNcycMHfUTszI52bjD19QR4AlReATPrOkA9PpvxVQ=; b=IOoyNwfny7E7SI15p7yhcLzy4qyjvbGc/RihMIYS12U3k2Qx/y2aK1QJExcpb9pQPK zMEUltZXhyya+iREu5ns1uiCHwctEUAVaU/soHhkAW3uf6iCsd0RD99YiRL0L5JlMdWG vVh9K5/j+6Y4WXIWRJuP0kQclygKp13/qzac6gvqsbkDwsyhgZZXESThx7hE+nsNqZmq DnEYGBw+fWmpMvdv2SuU2mM1gyqCP+SlEFlqW2SU1nmxQ2lGbSo4bbBaCYAdM7oYVQdS R5XC/WqFucXZFmEGcv6b9WfOhy0tAUovHskFMyJyjU5pWcEPqn2gC8znVPVrHkRVt1be r6Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0k7684Po; 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 s6si2011827ejo.502.2020.07.09.08.48.27; Thu, 09 Jul 2020 08:48:51 -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=default header.b=0k7684Po; 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 S1728047AbgGIPov (ORCPT + 99 others); Thu, 9 Jul 2020 11:44:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:46388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgGIPou (ORCPT ); Thu, 9 Jul 2020 11:44:50 -0400 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E5720207DA for ; Thu, 9 Jul 2020 15:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594309490; bh=aGxVb1DpozV7hPF11M4DsBqQ/F4gMscLyOHG8dL9j04=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=0k7684PoUgEkh6vKt/lEAefEnXoyZuetBeD96YkehKeEcFfnG5FYX2cJeuDYTvxBU 0UBwgrAxPCBHFrUeYigmgahHtSPX7eYVfI/gFc90zIDh3ysx3itLamOGDB18wZAOZJ EL2u8W+FVfqRRAvGV/P/gpYxQFxiMxitMzaCBIjQ= Received: by mail-oi1-f178.google.com with SMTP id j11so2202903oiw.12 for ; Thu, 09 Jul 2020 08:44:49 -0700 (PDT) X-Gm-Message-State: AOAM533UyP2eNzIB2A4jFY9kAfwi/ztGx7mWLAcsQpFdtWr+gq4dv8Q1 oRZdyh7beO1Mi37wYEMDsshwjSGvdIkJZWl1sA== X-Received: by 2002:aca:4844:: with SMTP id v65mr614541oia.152.1594309489279; Thu, 09 Jul 2020 08:44:49 -0700 (PDT) MIME-Version: 1.0 References: <20200614062730.46489-1-navid.emamdoost@gmail.com> In-Reply-To: <20200614062730.46489-1-navid.emamdoost@gmail.com> From: Rob Herring Date: Thu, 9 Jul 2020 09:44:36 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drm/panfrost: fix ref count leak in panfrost_job_hw_submit To: Navid Emamdoost Cc: Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , David Airlie , Daniel Vetter , dri-devel , "linux-kernel@vger.kernel.org" , Navid Emamdoost , wu000273@umn.edu, kjlu@umn.edu, Stephen McCamant Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 14, 2020 at 12:27 AM Navid Emamdoost wrote: > > in panfrost_job_hw_submit, 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_job.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c > index 7914b1570841..89ac84667eb1 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_job.c > +++ b/drivers/gpu/drm/panfrost/panfrost_job.c > @@ -147,11 +147,10 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) > > ret = pm_runtime_get_sync(pfdev->dev); > if (ret < 0) > - return; > + goto out; If the get failed, I don't think we want to do a put. > > if (WARN_ON(job_read(pfdev, JS_COMMAND_NEXT(js)))) { > - pm_runtime_put_sync_autosuspend(pfdev->dev); > - return; > + goto out; > } > > cfg = panfrost_mmu_as_get(pfdev, &job->file_priv->mmu); > @@ -184,6 +183,9 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) > job, js, jc_head); > > job_write(pfdev, JS_COMMAND_NEXT(js), JS_COMMAND_START); So we start the job here and then... > +out: > + pm_runtime_put_sync_autosuspend(pfdev->dev); ...turn off clocks/power here. Typically, you'd be fine as autosuspend has a delay by default, but userspace is free to change the delay to 0. > + return; > } > > static void panfrost_acquire_object_fences(struct drm_gem_object **bos, > -- > 2.17.1 >