Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-28 Thread David Hildenbrand
On 27.08.24 20:41, Peter Xu wrote: On Tue, Aug 27, 2024 at 08:00:07PM +0200, David Hildenbrand wrote: On 27.08.24 19:57, Peter Xu wrote: On Tue, Aug 27, 2024 at 10:37:15AM +0200, David Hildenbrand wrote: /* Called with ram_list.mutex held */ -static void dirty_memory_extend(ram_addr_t old_r

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread Peter Xu
On Tue, Aug 27, 2024 at 08:00:07PM +0200, David Hildenbrand wrote: > On 27.08.24 19:57, Peter Xu wrote: > > On Tue, Aug 27, 2024 at 10:37:15AM +0200, David Hildenbrand wrote: > > > /* Called with ram_list.mutex held */ > > > -static void dirty_memory_extend(ram_addr_t old_ram_size, > > > -

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread David Hildenbrand
On 27.08.24 19:57, Peter Xu wrote: On Tue, Aug 27, 2024 at 10:37:15AM +0200, David Hildenbrand wrote: /* Called with ram_list.mutex held */ -static void dirty_memory_extend(ram_addr_t old_ram_size, -ram_addr_t new_ram_size) +static void dirty_memory_extend(ram_a

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread David Hildenbrand
On 27.08.24 19:50, Peter Xu wrote: On Tue, Aug 27, 2024 at 01:28:02PM -0400, Stefan Hajnoczi wrote: On Tue, 27 Aug 2024 at 13:24, David Hildenbrand wrote: On 27.08.24 18:52, Stefan Hajnoczi wrote: On Tue, 27 Aug 2024 at 04:38, David Hildenbrand wrote: As reported by Peter, we might be lea

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread Peter Xu
On Tue, Aug 27, 2024 at 10:37:15AM +0200, David Hildenbrand wrote: > /* Called with ram_list.mutex held */ > -static void dirty_memory_extend(ram_addr_t old_ram_size, > -ram_addr_t new_ram_size) > +static void dirty_memory_extend(ram_addr_t new_ram_size) > { > -

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread Peter Xu
On Tue, Aug 27, 2024 at 01:28:02PM -0400, Stefan Hajnoczi wrote: > On Tue, 27 Aug 2024 at 13:24, David Hildenbrand wrote: > > > > On 27.08.24 18:52, Stefan Hajnoczi wrote: > > > On Tue, 27 Aug 2024 at 04:38, David Hildenbrand wrote: > > >> > > >> As reported by Peter, we might be leaking memory w

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread Stefan Hajnoczi
On Tue, 27 Aug 2024 at 13:24, David Hildenbrand wrote: > > On 27.08.24 18:52, Stefan Hajnoczi wrote: > > On Tue, 27 Aug 2024 at 04:38, David Hildenbrand wrote: > >> > >> As reported by Peter, we might be leaking memory when removing the > >> highest RAMBlock (in the weird ram_addr_t space), and a

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread David Hildenbrand
On 27.08.24 18:52, Stefan Hajnoczi wrote: On Tue, 27 Aug 2024 at 04:38, David Hildenbrand wrote: As reported by Peter, we might be leaking memory when removing the highest RAMBlock (in the weird ram_addr_t space), and adding a new one. We will fail to realize that we already allocated bitmaps

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread Stefan Hajnoczi
On Tue, 27 Aug 2024 at 04:38, David Hildenbrand wrote: > > As reported by Peter, we might be leaking memory when removing the > highest RAMBlock (in the weird ram_addr_t space), and adding a new one. > > We will fail to realize that we already allocated bitmaps for more > dirty memory blocks, and

Re: [PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread Peter Maydell
On Tue, 27 Aug 2024 at 09:37, David Hildenbrand wrote: > > As reported by Peter, we might be leaking memory when removing the > highest RAMBlock (in the weird ram_addr_t space), and adding a new one. > > We will fail to realize that we already allocated bitmaps for more > dirty memory blocks, and

[PATCH v1] softmmu/physmem: fix memory leak in dirty_memory_extend()

2024-08-27 Thread David Hildenbrand
As reported by Peter, we might be leaking memory when removing the highest RAMBlock (in the weird ram_addr_t space), and adding a new one. We will fail to realize that we already allocated bitmaps for more dirty memory blocks, and effectively discard the pointers to them. Fix it by getting rid of