fix unsigned integer subtraction sign overflow

Min_load, adjustment_load  and load are unsigned integers, so it overflows when (lb_info->min_load + info->load) < (lb_info->adjustment_load - info->load). The result will be greater than zero. Therefore the irq cannot be selected to rebalanced.
This commit is contained in:
liuchao173 2021-08-24 20:50:18 +08:00 committed by GitHub
parent c9a955dc9a
commit 2a66a666d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -97,7 +97,7 @@ static void move_candidate_irqs(struct irq_info *info, void *data)
}
/* If we can migrate an irq without swapping the imbalance do it. */
if ((lb_info->min_load + info->load) - (lb_info->adjustment_load - info->load) < delta_load) {
if ((lb_info->min_load + info->load) < delta_load + (lb_info->adjustment_load - info->load)) {
lb_info->adjustment_load -= info->load;
lb_info->min_load += info->load;
if (lb_info->min_load > lb_info->adjustment_load) {