Skip to content

Commit 8746c6c

Browse files
arunpravin24ChristianKoenigAMD
authored andcommitted
drm/buddy: Fix alloc_range() error handling code
Few users have observed display corruption when they boot the machine to KDE Plasma or playing games. We have root caused the problem that whenever alloc_range() couldn't find the required memory blocks the function was returning SUCCESS in some of the corner cases. The right approach would be if the total allocated size is less than the required size, the function should return -ENOSPC. Cc: <[email protected]> # 6.7+ Fixes: 0a1844b ("drm/buddy: Improve contiguous memory allocation") Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3097 Tested-by: Mario Limonciello <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Acked-by: Christian König <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Signed-off-by: Arunpravin Paneer Selvam <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Christian König <[email protected]>
1 parent b6ddaa6 commit 8746c6c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/gpu/drm/drm_buddy.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,12 @@ static int __alloc_range(struct drm_buddy *mm,
539539
} while (1);
540540

541541
list_splice_tail(&allocated, blocks);
542+
543+
if (total_allocated < size) {
544+
err = -ENOSPC;
545+
goto err_free;
546+
}
547+
542548
return 0;
543549

544550
err_undo:

0 commit comments

Comments
 (0)