kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] drm/amdgpu: fix a dereference on pointer hive before it is null checked
@ 2020-04-20 14:08 Colin King
  0 siblings, 0 replies; only message in thread
From: Colin King @ 2020-04-20 14:08 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Zhou, David Airlie,
	Daniel Vetter, Felix Kuehling, amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently pointer hive is being dereferenced before it is being null
checked and hence can lead to null pointer dereference issues. Fix this
by only dereferencing pointer hive after it has been null checked.

Addresses-Coverity: ("Dereference before null check")
Fixes: 25d4275e1931 ("drm/amdgpu: fix race between pstate and remote buffer map")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 54d8a3e7e75c..2c0a59ba2826 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -389,15 +389,17 @@ int amdgpu_xgmi_set_pstate(struct amdgpu_device *adev, int pstate)
 {
 	int ret = 0;
 	struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev, 0);
-	struct amdgpu_device *request_adev = hive->hi_req_gpu ?
-						hive->hi_req_gpu : adev;
+	struct amdgpu_device *request_adev;
 	bool is_hi_req = pstate = AMDGPU_XGMI_PSTATE_MAX_VEGA20;
-	bool init_low = hive->pstate = AMDGPU_XGMI_PSTATE_UNKNOWN;
+	bool init_low;
 
 	/* fw bug so temporarily disable pstate switching */
 	if (!hive || adev->asic_type = CHIP_VEGA20)
 		return 0;
 
+	request_adev = hive->hi_req_gpu ? hive->hi_req_gpu : adev;
+	init_low = hive->pstate = AMDGPU_XGMI_PSTATE_UNKNOWN;
+
 	mutex_lock(&hive->hive_lock);
 
 	if (is_hi_req)
-- 
2.25.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-20 14:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 14:08 [PATCH][next] drm/amdgpu: fix a dereference on pointer hive before it is null checked Colin King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).