Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp792760ybt; Sat, 13 Jun 2020 23:31:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl/8vTG5+Y7WLlQJMTtHd1yW5gsAlftLW13Ol7je3x/aJas3S6xlRg8gHIA826CpNIyxl8 X-Received: by 2002:a17:906:b88d:: with SMTP id hb13mr7959313ejb.96.1592116301708; Sat, 13 Jun 2020 23:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592116301; cv=none; d=google.com; s=arc-20160816; b=W0QvHxDtZak4d+MVo5V9vk7SvwNSZtUFifZn4o3DgKEBuAbjivijnTsOoCLKhcGjJN U/EmNl/XOL67hA3tbjis6npvQp0LQT1R28z5G29M8DZn8Bbjk9QjnLtSGs8PzaMhEII4 mt8vU4U5ZbUtyeBe89JiDdqDfhpyK/zy8oXwTDlmHa+wGTqdE+PlVAHMKKpkpst3jaDu ptQRgHs6ch61JGWhLk61c97Y0t8b9Zc7zRZID2VoeYe/6+TUJf5kjyOz1MFjAnSH3Akf GlkaJlOwxLteQOCEAtR9j9JOdtMsIxOp5aDNf+hqwxyMa0U/SQjc/rzkErKe9json04Q fJ6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=Pr9n4V8YJiXG+OQICtAk6o8sqO5Fm3+cCzZ+CtFDMKY=; b=Huwwg42qWbB8qXHeW08jI7/RI56HLcTT9saBa++0GvKp/s/iB+oap9d1Hfw6fxm248 lNWmVglQEFAIQFe7bPIIgW9YxZXRp8Jq0gDPC9vZdcbIYKwpM+cM8LS7dkuBswTALrHs FxnEKU5FeL7ZO8sUYWYpv6yFCC8m3WLCDUoqmNtiUt/Fn6DWdOCuji+dkfxKY9PhKKV4 Zyxuwl2tMzVYaeEmgaFk8LQMTCKcjOfh1opg+BWPni6dje0//bKO57bwwZhe9vJHy7Hy 1cvKSjbxPOjC/PM4CZ2lic8nvApbvNcjB9A+sOYP7cBZCwRsSNzVzOmnrpNHAmtX4KGu y0AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aCxS2eGX; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b24si496792edx.176.2020.06.13.23.31.19; Sat, 13 Jun 2020 23:31:41 -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=@gmail.com header.s=20161025 header.b=aCxS2eGX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbgFNG1j (ORCPT + 99 others); Sun, 14 Jun 2020 02:27:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725265AbgFNG1i (ORCPT ); Sun, 14 Jun 2020 02:27:38 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C61EC03E96F for ; Sat, 13 Jun 2020 23:27:37 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id q8so14503732iow.7 for ; Sat, 13 Jun 2020 23:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Pr9n4V8YJiXG+OQICtAk6o8sqO5Fm3+cCzZ+CtFDMKY=; b=aCxS2eGX+Ijgd2aSOJAZ0j+Xd/2Ni3mUe2bPVSeVpcqaLN05++JHFaQ+tcPnM5spHV OiPsQF11IErXnCbYOl86IYeo0Df7FeaPxui4jd3H/Ahu8PdzEKfEAiKuTBaeZLOw8qLj AN462QCPiiAwnF+Er0dVXpB6SpbF1+bO5TziaIRdM/7S63sdKzT2OfB8Dal+6fh/Sv+U ud+4NA4Qly4/EVM4VR9ilH9nDqzp/z36k/GzOdARN9H+oAtOSM/+XYbUjoG0oLLhm5AU P33hHC67x8C0P8yzI/W4sgFY8KX6GoHsxNcZ5Xq9/nYcuCNneW3S0l/TbH2ns7Zdaa62 dd3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Pr9n4V8YJiXG+OQICtAk6o8sqO5Fm3+cCzZ+CtFDMKY=; b=mXO4H0l+n7/Ko/lYIGiHGn9FglobkG4VAHBStVoWW50dhdP0pbEFqUWHXkNf2l8B9w 6TEYFo54tjhNlhLZfD/mAQ6WEc8TRR3ZdLb2+nBZkMMDE10pNcV85L/iJLmPCrGvmFBo 4RAPUA8LleTTy9XvHG5pSL3lHg0mAvG2N0twGYneFbcIwRtyVYgQwMpEXO7vifESsg8V 9Z9KjZ6MpiukQj3EwUfT0PKug4Th1OsBm8TqbgY1zZEOt/mjzoypUQihzZ2xmWJUpZhf I0zom7MU5jwTEqR+Q0FYcgdnkoZsYSSN9eDj1RoPh0OJhJsF3hXmYjbo/VgZUeSs9+oI ebrw== X-Gm-Message-State: AOAM530QvUxseTejMXdtUT3rafMvKRYwbpddgcesdNBMymb59Y8kmrSu 6A+PdzxxB82qucWQtW5SAAo= X-Received: by 2002:a05:6602:809:: with SMTP id z9mr21441256iow.79.1592116056556; Sat, 13 Jun 2020 23:27:36 -0700 (PDT) Received: from cs-u-kase.dtc.umn.edu (cs-u-kase.cs.umn.edu. [160.94.64.2]) by smtp.googlemail.com with ESMTPSA id b22sm5769329ios.21.2020.06.13.23.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jun 2020 23:27:36 -0700 (PDT) From: Navid Emamdoost To: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: emamd001@umn.edu, wu000273@umn.edu, kjlu@umn.edu, smccaman@umn.edu, Navid Emamdoost Subject: [PATCH] drm/panfrost: fix ref count leak in panfrost_job_hw_submit Date: Sun, 14 Jun 2020 01:27:30 -0500 Message-Id: <20200614062730.46489-1-navid.emamdoost@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 (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); +out: + pm_runtime_put_sync_autosuspend(pfdev->dev); + return; } static void panfrost_acquire_object_fences(struct drm_gem_object **bos, -- 2.17.1