[PATCH v2] drm: Fix a infinite loop condition when order becomes 0

Christian König ckoenig.leichtzumerken at gmail.com
Wed Mar 16 12:32:47 UTC 2022


Am 16.03.22 um 12:31 schrieb Matthew Auld:
> On 16/03/2022 06:34, Arunpravin Paneer Selvam wrote:
>> handle a situation in the condition order-- == min_order,
>> when order = 0 and min_order = 0, leading to order = -1,
>> it now won't exit the loop. To avoid this problem,
>> added a order check in the same condition, (i.e)
>> when order is 0, we return -ENOSPC
>>
>> v2: use full name in email program and in Signed-off tag
>>
>> Signed-off-by: Arunpravin Paneer Selvam 
>> <Arunpravin.PaneerSelvam at amd.com>
>> ---
>>   drivers/gpu/drm/drm_buddy.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
>> index 72f52f293249..5ab66aaf2bbd 100644
>> --- a/drivers/gpu/drm/drm_buddy.c
>> +++ b/drivers/gpu/drm/drm_buddy.c
>> @@ -685,7 +685,7 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm,
>>               if (!IS_ERR(block))
>>                   break;
>>   -            if (order-- == min_order) {
>> +            if (!order || order-- == min_order) {
>
> It shouldn't be possible to enter an infinite loop here, without first 
> tripping up the BUG_ON(order < min_order) further up, and for that, as 
> we discussed here[1], it sounded like the conclusion was to rather add 
> a simple check somewhere in drm_buddy_alloc_blocks() to reject any 
> size not aligned to the min_page_size?

Sounds good to me as well.

And just to make it clear: I don't review the functionality here, that's 
up to you guys.

Just giving my Ack on things like style and pushing the end result 
upstream as necessary.

So let me know when you have settled on a solution.

Regards,
Christian.

>
> [1] https://patchwork.freedesktop.org/patch/477414/?series=101108&rev=1
>
>>                   err = -ENOSPC;
>>                   goto err_free;
>>               }
>>
>> base-commit: 3bd60c0259406c5ca3ce5cdc958fb910ad4b8175



More information about the dri-devel mailing list