AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu: Fix uninitialized variable warning in amdgpu_info_ioctl
@ 2024-05-06  9:56 Ma Jun
  2024-05-06  9:56 ` [PATCH 2/2] drm/amdgpu/pm: Fix the param type of set_power_profile_mode Ma Jun
  2024-05-06 15:21 ` [PATCH 1/2] drm/amdgpu: Fix uninitialized variable warning in amdgpu_info_ioctl Alex Deucher
  0 siblings, 2 replies; 3+ messages in thread
From: Ma Jun @ 2024-05-06  9:56 UTC (permalink / raw)
  To: amd-gfx
  Cc: Kenneth.Feng, Alexander.Deucher, kevinyang.wang, christian.koenig,
	Ma Jun

Check the return value of amdgpu_xcp_get_inst_details, otherwise we
may use an uninitialized variable inst_mask

Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index a0ea6fe8d060..977cde6d1362 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -623,25 +623,32 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 			switch (type) {
 			case AMD_IP_BLOCK_TYPE_GFX:
 				ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_GFX, &inst_mask);
+				if (ret)
+					return ret;
 				count = hweight32(inst_mask);
 				break;
 			case AMD_IP_BLOCK_TYPE_SDMA:
 				ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_SDMA, &inst_mask);
+				if (ret)
+					return ret;
 				count = hweight32(inst_mask);
 				break;
 			case AMD_IP_BLOCK_TYPE_JPEG:
 				ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_VCN, &inst_mask);
+				if (ret)
+					return ret;
 				count = hweight32(inst_mask) * adev->jpeg.num_jpeg_rings;
 				break;
 			case AMD_IP_BLOCK_TYPE_VCN:
 				ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_VCN, &inst_mask);
+				if (ret)
+					return ret;
 				count = hweight32(inst_mask);
 				break;
 			default:
 				return -EINVAL;
 			}
-			if (ret)
-				return ret;
+
 			return copy_to_user(out, &count, min(size, 4u)) ? -EFAULT : 0;
 		}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-06 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-06  9:56 [PATCH 1/2] drm/amdgpu: Fix uninitialized variable warning in amdgpu_info_ioctl Ma Jun
2024-05-06  9:56 ` [PATCH 2/2] drm/amdgpu/pm: Fix the param type of set_power_profile_mode Ma Jun
2024-05-06 15:21 ` [PATCH 1/2] drm/amdgpu: Fix uninitialized variable warning in amdgpu_info_ioctl Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox