From: jsg Date: Mon, 9 Sep 2024 09:22:20 +0000 (+0000) Subject: drm/amdgpu: fix ucode out-of-bounds read warning X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=093e7a1454e12cc6f937d9b690b75519e2d0b4c1;p=openbsd drm/amdgpu: fix ucode out-of-bounds read warning From Tim Huang f2b7a9f3839e92f43559b2795b34640ca8cf839f in linux-6.6.y/6.6.50 8944acd0f9db33e17f387fdc75d33bb473d7936f in mainline linux --- diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_cgs.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_cgs.c index 4f1da1227a7..637cd3f74e9 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_cgs.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_cgs.c @@ -213,6 +213,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, struct amdgpu_firmware_info *ucode; id = fw_type_convert(cgs_device, type); + if (id >= AMDGPU_UCODE_ID_MAXIMUM) + return -EINVAL; + ucode = &adev->firmware.ucode[id]; if (ucode->fw == NULL) return -EINVAL;