diff options
author | Donald Robson <donald.robson@imgtec.com> | 2023-12-08 19:08:25 +0300 |
---|---|---|
committer | Maxime Ripard <mripard@kernel.org> | 2023-12-15 16:03:57 +0300 |
commit | b39610c773431ac7991cf6235e26d693ccabd9e9 (patch) | |
tree | 02ebe33ce06ca2a529a1b0e20c0594835036625a /drivers/gpu/drm/imagination | |
parent | b1a2aa9bcbb88a7dc1c4df98dbf4f4df9ca79c9f (diff) | |
download | linux-b39610c773431ac7991cf6235e26d693ccabd9e9.tar.xz |
drm/imagination: Fixed infinite loop in pvr_vm_mips_map()
Unwinding loop in error path for this function uses unsigned limit
variable, causing the promotion of the signed counter variable.
--> 204 for (; pfn >= start_pfn; pfn--)
^^^^^^^^^^^^^^^^
If start_pfn can be zero then this is an endless loop. I've seen this
code in other places as well. This loop is slightly off as well. It
should decrement pfn on the first iteration.
Fix by making the loop limit variables signed. Also fix missing
predecrement by modifying to while loop.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Donald Robson <donald.robson@imgtec.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20231208160825.92933-1-donald.robson@imgtec.com
Diffstat (limited to 'drivers/gpu/drm/imagination')
-rw-r--r-- | drivers/gpu/drm/imagination/pvr_vm_mips.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/gpu/drm/imagination/pvr_vm_mips.c b/drivers/gpu/drm/imagination/pvr_vm_mips.c index 2bc7181a4c3e..b7fef3c797e6 100644 --- a/drivers/gpu/drm/imagination/pvr_vm_mips.c +++ b/drivers/gpu/drm/imagination/pvr_vm_mips.c @@ -152,8 +152,8 @@ pvr_vm_mips_map(struct pvr_device *pvr_dev, struct pvr_fw_object *fw_obj) u64 end; u32 cache_policy; u32 pte_flags; - u32 start_pfn; - u32 end_pfn; + s32 start_pfn; + s32 end_pfn; s32 pfn; int err; @@ -201,7 +201,7 @@ pvr_vm_mips_map(struct pvr_device *pvr_dev, struct pvr_fw_object *fw_obj) return 0; err_unmap_pages: - for (; pfn >= start_pfn; pfn--) + while (--pfn >= start_pfn) WRITE_ONCE(mips_data->pt[pfn], 0); pvr_mmu_flush_request_all(pvr_dev); |