Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2491183pxa; Mon, 17 Aug 2020 10:55:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyug/sJwlIUSMGxv8TOaJ3iTSinY/iHB7BzWVEMbv9nS4GYZ5ADUH91fiKo0JFSf4Gpl5su X-Received: by 2002:a17:906:c7d4:: with SMTP id dc20mr17187265ejb.283.1597686916975; Mon, 17 Aug 2020 10:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597686916; cv=none; d=google.com; s=arc-20160816; b=Suo0RdFOzh42Br23VGjqRom43Y84uR0fZQAlD0HtEMECWYOZVyE9X7KqR/jDOFgbUF jCoCHe8kRACYerCrv7BaQTl8pByRnvmBFGUtJ2J1fLjwmw7g2YyPWNh4BImQJb90fjj+ E7SMPtYb9CcDXzqrF957A+yzWS4HFKOeTlerqzQ8KwnQECpBEXSBIj33t0IFgWtoduu6 r5/pDm0hy+9fxdTh9XG9kkUsmMKoe895tii6pRac/MH2yqQ5e5ykS40c5tnnN4vP3P1u xW+6kLA5pQNzJikLnd4G6/NIpu30KdtbsP2M9roz/2ef+tq+etmNiF9pkEjkKWlhhxC+ Qyjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fSKjVnZWiGrM8pml/XV6bFAmweMY61gVA1gZTMx67vs=; b=MmysnFozxhuZ51a2w7nenoTW+Hi40waLm16H4pT9urtOjk6EW7Zp2Z1spLqqbFrGhP IXl6ahTH7/HvunEJc1b1Yvr6d5wd20V7mrI7/OGz4HW+zOcORpt9/j6OLlfq40r5UTeU cHzkKiN8WqQZQs2E8O7W6xetIwEvrn3z8U1U7dOZoEkmyIWaEeDyqN7ZdtBoZCliUTtW onVooGaHnkl/PMOD4P0G8742Q4PsKMU5yCzOJprgoRrCMPZlKz5FiESFomzFxFObbeHf W+uiQrZkABRhr3gBuFuHDigkfCReoMub+smHerAyDZHZuV82VjUoPKV+QCie8sr7d6At A6Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OrvKnHdf; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d24si11802573edz.145.2020.08.17.10.54.52; Mon, 17 Aug 2020 10:55:16 -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=OrvKnHdf; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390025AbgHQRuy (ORCPT + 99 others); Mon, 17 Aug 2020 13:50:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:42810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388431AbgHQQMF (ORCPT ); Mon, 17 Aug 2020 12:12:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7710522CA0; Mon, 17 Aug 2020 16:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680724; bh=oQ0uPvUk3cWTbfw3EQOsapSTZSuYYtxomEmeBV3SuSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OrvKnHdfb5XHs1kl7mL6Npsy4QWZ9fJZfADMB5/8DnDCsFELkYnEuzk5Jpm1NefF3 YNv98dKm339CQ4eFv8r+YUqj8UR81MliTD2O2eMAlNyLrK9djeP1zJwH7srM+FTS5U NVaYQNz7I6yt1Zfs1y1QQX43MTCayMQnHz3AyFzk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Xiao , Alex Deucher , Hawking Zhang , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sasha Levin Subject: [PATCH 4.19 030/168] drm/amdgpu: avoid dereferencing a NULL pointer Date: Mon, 17 Aug 2020 17:16:01 +0200 Message-Id: <20200817143735.262185363@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143733.692105228@linuxfoundation.org> References: <20200817143733.692105228@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jack Xiao [ Upstream commit 55611b507fd6453d26030c0c0619fdf0c262766d ] Check if irq_src is NULL to avoid dereferencing a NULL pointer, for MES ring is uneccessary to recieve an interrupt notification. Signed-off-by: Jack Xiao Acked-by: Alex Deucher Reviewed-by: Hawking Zhang Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 869ff624b108c..e5e51e4d4f3d8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -396,7 +396,9 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring, ring->fence_drv.gpu_addr = adev->uvd.inst[ring->me].gpu_addr + index; } amdgpu_fence_write(ring, atomic_read(&ring->fence_drv.last_seq)); - amdgpu_irq_get(adev, irq_src, irq_type); + + if (irq_src) + amdgpu_irq_get(adev, irq_src, irq_type); ring->fence_drv.irq_src = irq_src; ring->fence_drv.irq_type = irq_type; @@ -508,8 +510,9 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev) /* no need to trigger GPU reset as we are unloading */ amdgpu_fence_driver_force_completion(ring); } - amdgpu_irq_put(adev, ring->fence_drv.irq_src, - ring->fence_drv.irq_type); + if (ring->fence_drv.irq_src) + amdgpu_irq_put(adev, ring->fence_drv.irq_src, + ring->fence_drv.irq_type); drm_sched_fini(&ring->sched); del_timer_sync(&ring->fence_drv.fallback_timer); for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) @@ -545,8 +548,9 @@ void amdgpu_fence_driver_suspend(struct amdgpu_device *adev) } /* disable the interrupt */ - amdgpu_irq_put(adev, ring->fence_drv.irq_src, - ring->fence_drv.irq_type); + if (ring->fence_drv.irq_src) + amdgpu_irq_put(adev, ring->fence_drv.irq_src, + ring->fence_drv.irq_type); } } @@ -572,8 +576,9 @@ void amdgpu_fence_driver_resume(struct amdgpu_device *adev) continue; /* enable the interrupt */ - amdgpu_irq_get(adev, ring->fence_drv.irq_src, - ring->fence_drv.irq_type); + if (ring->fence_drv.irq_src) + amdgpu_irq_get(adev, ring->fence_drv.irq_src, + ring->fence_drv.irq_type); } } -- 2.25.1