]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amdgpu: Avoid integer overflow in amdgpu_device_suspend_display_audio
authorNathan Chancellor <natechancellor@gmail.com>
Sat, 2 May 2020 03:11:41 +0000 (20:11 -0700)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 5 May 2020 17:12:55 +0000 (13:12 -0400)
When building with Clang:

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:4160:53: warning: overflow in
expression; result is -294967296 with type 'long' [-Winteger-overflow]
                expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4L;
                                                                  ^
1 warning generated.

Multiplication happens first due to order of operations and both
NSEC_PER_SEC and 4 are long literals so the expression overflows. To
avoid this, make 4 an unsigned long long literal, which matches the
type of expires (u64).

Fixes: 79dedd8cf74d ("drm/amdgpu: put the audio codec into suspend state before gpu reset V3")
Link: https://github.com/ClangBuiltLinux/linux/issues/1017
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 6f93af972b0ae1cdcd57a6404bac0ca2b08b156a..caa38e7d502e5ee90688355a64d7f682c5c26299 100644 (file)
@@ -4157,7 +4157,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
                 * the audio controller default autosuspend delay setting.
                 * 4S used here is guaranteed to cover that.
                 */
-               expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4L;
+               expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4ULL;
 
        while (!pm_runtime_status_suspended(&(p->dev))) {
                if (!pm_runtime_suspend(&(p->dev)))