From patchwork Thu Apr 21 20:34:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 12822407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EDE02C433EF for ; Thu, 21 Apr 2022 20:41:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C9D3E10E05E; Thu, 21 Apr 2022 20:41:57 +0000 (UTC) X-Greylist: delayed 372 seconds by postgrey-1.36 at gabe; Thu, 21 Apr 2022 20:41:56 UTC Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E7E010E053; Thu, 21 Apr 2022 20:41:56 +0000 (UTC) Received: from g550jk.arnhem.chello.nl (a246182.upc-a.chello.nl [62.163.246.182]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 1910FCC043; Thu, 21 Apr 2022 20:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=z3ntu.xyz; s=z3ntu; t=1650573312; bh=Wx/zCUfbsxDCv8xhISdDZZirNu+1fzyBwddjK0yGyOg=; h=From:To:Cc:Subject:Date; b=CQUxwhoVAz4cdMEfo9dta2JoY5jVEcOoXhXsXr+EnXMmkay599as3FhA4d/Zx5sZY 5ZO/7/wOn1oxMgMwVbc87vRWZn4mEfaN38jiPb3+zUlVhdbEor4HKprwLja/gKpYfd Bbr2mwmKx9vVTk4tmYQ8oI3KyqMkA4naO4NVQb9s= From: Luca Weiss To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/msm: Fix null pointer dereferences without iommu Date: Thu, 21 Apr 2022 22:34:53 +0200 Message-Id: <20220421203455.313523-1-luca@z3ntu.xyz> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 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: freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Emma Anholt , Jonathan Marek , David Airlie , linux-arm-msm@vger.kernel.org, Stephen Boyd , Abhinav Kumar , Jordan Crouse , Luca Weiss , Akhil P Oommen , ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Sean Paul , Dan Carpenter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Check if 'aspace' is set before using it as it will stay null without IOMMU, such as on msm8974. Fixes: bc2112583a0b ("drm/msm/gpu: Track global faults per address-space") Signed-off-by: Luca Weiss --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 5 ++++- drivers/gpu/drm/msm/msm_gpu.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index 9efc84929be0..1219f71629a5 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -272,7 +272,10 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx, *value = 0; return 0; case MSM_PARAM_FAULTS: - *value = gpu->global_faults + ctx->aspace->faults; + if (ctx->aspace) + *value = gpu->global_faults + ctx->aspace->faults; + else + *value = gpu->global_faults; return 0; case MSM_PARAM_SUSPENDS: *value = gpu->suspend_count; diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index faf0c242874e..58eb3e1662cb 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -371,7 +371,8 @@ static void recover_worker(struct kthread_work *work) /* Increment the fault counts */ submit->queue->faults++; - submit->aspace->faults++; + if (submit->aspace) + submit->aspace->faults++; task = get_pid_task(submit->pid, PIDTYPE_PID); if (task) {