Just imaging the case where num_pages < BITS_PER_LONG, then the loop will be skipped while it shouldn't.
Unified · Split
| @@ -1264,8 +1264,8 @@ int kvm_clear_dirty_log_protect(struct kvm *kvm, · 1263 unmodified lines | ||
| 1264 | 1264 | return -EFAULT; |
| 1265 | 1265 | |
| 1266 | 1266 | spin_lock(&kvm->mmu_lock); |
| 1267 | − for (offset = log->first_page, | |
| 1268 | − i = offset / BITS_PER_LONG, n = log->num_pages / BITS_PER_LONG; n--; | |
| 1267 | + for (offset = log->first_page, i = offset / BITS_PER_LONG, | |
| 1268 | + n = DIV_ROUND_UP(log->num_pages, BITS_PER_LONG); n--; | |
| 1269 | 1269 | i++, offset += BITS_PER_LONG) { |
| 1270 | 1270 | unsigned long mask = *dirty_bitmap_buffer++; |
| 1271 | 1271 | atomic_long_t *p = (atomic_long_t *) &dirty_bitmap[i]; |