Skip to content

Commit 9ff335e

Browse files
committedFeb 12, 2022
Fix memory leak of the empty_view
1 parent 5683a54 commit 9ff335e

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed
 

‎qemu/softmmu/memory.c

+1-11
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ static FlatView *generate_memory_topology(struct uc_struct *uc, MemoryRegion *mr
685685
{
686686
int i;
687687
FlatView *view;
688-
FlatView *old_view;
689688

690689
view = flatview_new(mr);
691690

@@ -703,14 +702,7 @@ static FlatView *generate_memory_topology(struct uc_struct *uc, MemoryRegion *mr
703702
flatview_add_to_dispatch(uc, view, &mrs);
704703
}
705704
address_space_dispatch_compact(view->dispatch);
706-
707-
old_view = g_hash_table_lookup(uc->flat_views, mr);
708-
if (old_view != view) {
709-
g_hash_table_replace(uc->flat_views, mr, view);
710-
if (old_view) {
711-
flatview_unref(old_view);
712-
}
713-
}
705+
g_hash_table_replace(uc->flat_views, mr, view);
714706

715707
return view;
716708
}
@@ -794,9 +786,7 @@ static void flatviews_init(struct uc_struct *uc)
794786
uc->empty_view = generate_memory_topology(uc, NULL);
795787
/* We keep it alive forever in the global variable. */
796788
flatview_ref(uc->empty_view);
797-
} else {
798789
g_hash_table_replace(uc->flat_views, NULL, uc->empty_view);
799-
flatview_ref(uc->empty_view);
800790
}
801791
}
802792

0 commit comments

Comments
 (0)
Please sign in to comment.