qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 2/3] softmmu/ioport.c: QOMify MemoryRegionPortioList
Date: Thu, 11 May 2023 15:50:29 +0200	[thread overview]
Message-ID: <2d36555a-b5c6-ac21-c1d3-a8668a05a7eb@linaro.org> (raw)
In-Reply-To: <20230419151652.362717-3-mark.cave-ayland@ilande.co.uk>

On 19/4/23 17:16, Mark Cave-Ayland wrote:
> The aim of QOMification is so that the lifetime of the MemoryRegionPortioList
> structure can be managed using QOM's in-built refcounting instead of having to
> handle this manually.
> 
> Due to the use of an opaque pointer it isn't possible to model the new
> TYPE_MEMORY_REGION_PORTIO_LIST directly using QOM properties, however since
> use of the new object is restricted to the portio API we can simply set the
> opaque pointer (and the heap-allocated port list) internally.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   softmmu/ioport.c | 25 ++++++++++++++++++++++---
>   1 file changed, 22 insertions(+), 3 deletions(-)


>   static uint64_t unassigned_io_read(void *opaque, hwaddr addr, unsigned size)
>   {
> @@ -228,7 +233,8 @@ static void portio_list_add_1(PortioList *piolist,
>       unsigned i;
>   
>       /* Copy the sub-list and null-terminate it.  */
> -    mrpio = g_malloc0(sizeof(MemoryRegionPortioList));
> +    mrpio = MEMORY_REGION_PORTIO_LIST(
> +                object_new(TYPE_MEMORY_REGION_PORTIO_LIST));

Shouldn't we need to replace the g_free() call by object_unref()
in portio_list_destroy()?

>       mrpio->portio_opaque = piolist->opaque;
>       mrpio->ports = g_malloc0(sizeof(MemoryRegionPortio) * (count + 1));
>       memcpy(mrpio->ports, pio_init, sizeof(MemoryRegionPortio) * count);
> @@ -298,3 +304,16 @@ void portio_list_del(PortioList *piolist)
>           memory_region_del_subregion(piolist->address_space, &mrpio->mr);
>       }
>   }



  parent reply	other threads:[~2023-05-11 13:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19 15:16 [PATCH 0/3] softmmu/ioport.c: fix use-after-free when calling portio_list_destroy() Mark Cave-Ayland
2023-04-19 15:16 ` [PATCH 1/3] softmmu/ioport.c: allocate MemoryRegionPortioList ports on the heap Mark Cave-Ayland
2023-04-20  8:37   ` Philippe Mathieu-Daudé
2023-04-19 15:16 ` [PATCH 2/3] softmmu/ioport.c: QOMify MemoryRegionPortioList Mark Cave-Ayland
2023-04-20  8:41   ` Philippe Mathieu-Daudé
2023-04-20 10:53     ` Mark Cave-Ayland
2023-05-11 13:46   ` Philippe Mathieu-Daudé
2023-05-11 14:43     ` Mark Cave-Ayland
2023-05-17 16:31       ` Paolo Bonzini
2023-05-11 13:50   ` Philippe Mathieu-Daudé [this message]
2023-05-11 14:52     ` Mark Cave-Ayland
2023-05-17 16:37       ` Paolo Bonzini
2023-04-19 15:16 ` [PATCH 3/3] softmmu/ioport.c: make MemoryRegionPortioList owner of portio_list MemoryRegions Mark Cave-Ayland
2023-05-11 19:22   ` Philippe Mathieu-Daudé
2023-05-12  6:56     ` Mark Cave-Ayland
2023-05-12 14:13       ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2d36555a-b5c6-ac21-c1d3-a8668a05a7eb@linaro.org \
    --to=philmd@linaro.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).