rcu_read_unlock();
return -ENOMEM;
}
- gap = mas.index & ~(info->align_mask);
- gap += info->align_offset;
- } while ((gap < mas.index) && (gap > mas.last - info->length + 1));
+ gap = mas.index;
+ gap += (info->align_offset - mas.index) & info->align_mask;
+ } while ((mas.index > gap) && (gap > mas.last - info->length + 1));
rcu_read_unlock();
return gap;
return -ENOMEM;
}
- gap = mas.last - info->length + 1;
- gap &= ~(info->align_mask);
- gap += info->align_offset;
- } while (mas.index > gap);
+ gap = mas.last + 1 - info->length;
+ gap -= (gap - info->align_offset) & info->align_mask;
+ } while ((mas.index > gap) && (mas.last > gap + info->length - 1));
rcu_read_unlock();
return gap;