mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
drm/amdgpu: Fix uninitialized variable warning in amdgpu_info_ioctl
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> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user