Skip to content

Commit beb15a6

Browse files
Stanislav Kinsburskiiliuw
authored andcommitted
mshv: Initialize local variables early upon region invalidation
Ensure local variables are initialized before use so that the warning can print the right values if locking the region to invalidate fails due to inability to lock the region. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Fixes: b9a66cd ("mshv: Add support for movable memory regions") Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 3a2bcc1 commit beb15a6

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/hv/mshv_regions.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -494,20 +494,20 @@ static bool mshv_region_interval_invalidate(struct mmu_interval_notifier *mni,
494494
unsigned long mstart, mend;
495495
int ret = -EPERM;
496496

497-
if (mmu_notifier_range_blockable(range))
498-
mutex_lock(&region->mutex);
499-
else if (!mutex_trylock(&region->mutex))
500-
goto out_fail;
501-
502-
mmu_interval_set_seq(mni, cur_seq);
503-
504497
mstart = max(range->start, region->start_uaddr);
505498
mend = min(range->end, region->start_uaddr +
506499
(region->nr_pages << HV_HYP_PAGE_SHIFT));
507500

508501
page_offset = HVPFN_DOWN(mstart - region->start_uaddr);
509502
page_count = HVPFN_DOWN(mend - mstart);
510503

504+
if (mmu_notifier_range_blockable(range))
505+
mutex_lock(&region->mutex);
506+
else if (!mutex_trylock(&region->mutex))
507+
goto out_fail;
508+
509+
mmu_interval_set_seq(mni, cur_seq);
510+
511511
ret = mshv_region_remap_pages(region, HV_MAP_GPA_NO_ACCESS,
512512
page_offset, page_count);
513513
if (ret)

0 commit comments

Comments
 (0)