Fix unintentional integer overflow
Subsystems (2)
Fix overflow issue by casting uint8_t to uint64_t in JPEG instance multiplication.
The expression's value may not be what the programmer intended, because the expression is evaluated using
a narrow (i.e. few bits) integer type.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c +1 -1
@@ -357,7 +357,7 @@ static int amdgpu_debugfs_jpeg_sched_mask_set(void *data, u64 val)if (!adev)return -ENODEV ; - mask = (1 << (adev->jpeg.num_jpeg_inst * adev->jpeg.num_jpeg_rings)) -1 ; + mask = ((uint64_t )1 << (adev->jpeg.num_jpeg_inst * adev->jpeg.num_jpeg_rings)) -1 ;if ((val & mask) ==0 )return -EINVAL ;
Signature · 1 line
2.34.1
Quoted 2 lines · Advait Dhamorikar
Fix overflow issue by casting
uint8_ttouint64_tin JPEG instance multiplication.
Thank you for the fix, u8 isn't the default it is usually treated as int, is it okay to mention "fix shift-count-overflow in.."
or something else of your choice , but not u8. And if possible, please align the end of commit description on all lines closer to each other(only where possible, else it is okay).
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c:361:12: error: left shift count >= width of type [-Werror=shift-count-overflow] 361 | mask = (1 << 32) - 1;
Regards,
Sathish
Quoted 23 lines
The expression's value may not be what the programmer intended, because the expression is evaluated using
a narrow (i.e. few bits) integer type.Fixes f0b19b84d391 ("drm/amdgpu: add amdgpu_jpeg_sched_mask debugfs")Signed-off-by Advait Dhamorikar<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c +1
-1@@ -357,7 +357,7 @@ static int amdgpu_debugfs_jpeg_sched_mask_set(void *data, u64 val)if (!adev)return -ENODEV ; - mask = (1 << (adev->jpeg.num_jpeg_inst * adev->jpeg.num_jpeg_rings)) -1 ; + mask = ((uint64_t )1 << (adev->jpeg.num_jpeg_inst * adev->jpeg.num_jpeg_rings)) -1 ;if ((val & mask) ==0 )return -EINVAL ;