On 05.02.2024 16:14, Andrew Cooper wrote:
> @@ -263,7 +266,7 @@ int bitmap_find_free_region(unsigned long *bitmap, 
> unsigned int bits, unsigned i
>       unsigned int pages = 1 << order;

If we mean to keep this function (see my reply to the other patch),
shouldn't we also check "order" along with

>       unsigned int i;
>  
> -     if(pages > BITS_PER_LONG)
> +     if (pages > BITS_PER_LONG || bits >= INT_MAX)
>               return -EINVAL;

... these checks?

> @@ -278,7 +281,7 @@ int bitmap_find_free_region(unsigned long *bitmap, 
> unsigned int bits, unsigned i
>               if((bitmap[index] & (mask << offset)) == 0) {
>                       /* set region in bimap */
>                       bitmap[index] |= (mask << offset);
> -                     return i;
> +                     return (int)i;

I agree with Julien that it looks like this change actually belongs in
the other patch.

Jan

Reply via email to