Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2656541pxa; Mon, 17 Aug 2020 15:41:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTMaZ9OussrhhNOe1SQT40S/LLb7ZVobIxjkO2V+JHEtBmyr70hvsK87q6orVUxVOUXCkb X-Received: by 2002:a50:af83:: with SMTP id h3mr17205750edd.139.1597704099350; Mon, 17 Aug 2020 15:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704099; cv=none; d=google.com; s=arc-20160816; b=PFkDWM5MQk5CYDh6NgfuRzCMuNk29moNlLfgyBo7QZ0s5ofwTdXSXST47DYEbnGc2d QIZgKdnHY/cZtGQSvTnDkReoxnjF6lMoHatReL87mAYAG+JLlZ6o5Vp5TA/DJwNrM16X Xy0L4vcn2QLv0kq6ey8Doha/VnjT5R7KKwijnR9dk+fqeEnipLYxWUn74Dop/PL+YZ2B 3lFT7k8OYkIebTtOWS3JNzWuCK7Fu8ylkprlIlxfMfCD8FZ368kYWAR1GtzPb/clyVf3 cCnUgrd9Mo0mWLvQ5LfmTBprehm/jyOOUSlyxSENK29NaFMjIe3SZuwFAnx3o7daAVJ0 drcQ== 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=deB6GwyRxNrQxrvhI7UAZBs0+ZGIkeiP04MEEGg1A4g=; b=PL9+EsGc3j26cAlU03P8XvUQm8raBZF5GzRdx704GYB1TIhHVGOGLAZVlU/VQwAaco jRMLKczs5quh5UtZxlggwoAkC2G3B6y+L6dwZKPCFoKewNV9Y830Nn+Si6RXp4d6WRP3 ARDDwRyS4dFeWUXl6JWhoNS2/Z4HCrMG0ooNniS+ffVPT4ivyHKFKO60Owke/OFtNfPS Yv4479UViQ0RGvlCy7w0vaebvbg8oHHThF/rPO+drnnScwBp3RNY0snWtRK44RdnJiAq oN15KnuvInY1wd5s2iq4dKZiEyOiT+ejCVgcfhMcochbHI5mGzogdjszAde0J2gD7Ai4 dQRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zogNlOEb; 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 o18si11254443ejg.391.2020.08.17.15.41.15; Mon, 17 Aug 2020 15:41:39 -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=zogNlOEb; 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 S2391033AbgHQS3o (ORCPT + 99 others); Mon, 17 Aug 2020 14:29:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:49086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388156AbgHQQBr (ORCPT ); Mon, 17 Aug 2020 12:01:47 -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 628B320829; Mon, 17 Aug 2020 16:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680098; bh=POih9G7UqkC5Ul1MYzi3N3eD1nRn5F7/aPLt0IzppNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zogNlOEbEwmvDCwc6UTB3H1KB8GPlROBQapTJvzIhxnRS2FuBqnfjwFOP30OLXerW VO7VbIXEjqT1ASSBNUCR0DmzMzeKumWDATeDXET2nQTtr59uGuF9Pigi40RJg/xHVA 2HLUyHxdgGszG8maune5oQenFPFqp0YJ5iWjFeG0= 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 5.4 051/270] drm/amdgpu: avoid dereferencing a NULL pointer Date: Mon, 17 Aug 2020 17:14:12 +0200 Message-Id: <20200817143758.319695268@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@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 23085b352cf2d..c212d5fc665c6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -404,7 +404,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; @@ -539,8 +541,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) @@ -576,8 +579,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); } } @@ -603,8 +607,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