Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Ma Jun and committed by
Alex Deucher
0991e49d d768394f

+9 -2
+9 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
··· 623 623 switch (type) { 624 624 case AMD_IP_BLOCK_TYPE_GFX: 625 625 ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_GFX, &inst_mask); 626 + if (ret) 627 + return ret; 626 628 count = hweight32(inst_mask); 627 629 break; 628 630 case AMD_IP_BLOCK_TYPE_SDMA: 629 631 ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_SDMA, &inst_mask); 632 + if (ret) 633 + return ret; 630 634 count = hweight32(inst_mask); 631 635 break; 632 636 case AMD_IP_BLOCK_TYPE_JPEG: 633 637 ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_VCN, &inst_mask); 638 + if (ret) 639 + return ret; 634 640 count = hweight32(inst_mask) * adev->jpeg.num_jpeg_rings; 635 641 break; 636 642 case AMD_IP_BLOCK_TYPE_VCN: 637 643 ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_VCN, &inst_mask); 644 + if (ret) 645 + return ret; 638 646 count = hweight32(inst_mask); 639 647 break; 640 648 default: 641 649 return -EINVAL; 642 650 } 643 - if (ret) 644 - return ret; 651 + 645 652 return copy_to_user(out, &count, min(size, 4u)) ? -EFAULT : 0; 646 653 } 647 654