qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fan Ni <fan.ni@samsung.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Michael Tsirkin" <mst@redhat.com>,
	"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
	"Li Zhijian" <lizhijian@cn.fujitsu.com>,
	"Dave Jiang" <dave.jiang@intel.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"linuxarm@huawei.com" <linuxarm@huawei.com>
Subject: Re: [PATCH 1/4] hw/cxl: Fix CFMW config memory leak
Date: Tue, 12 Sep 2023 21:22:34 +0000	[thread overview]
Message-ID: <20230912212225.GA2859961@sjcvldevvm72> (raw)
In-Reply-To: <20230904132806.6094-2-Jonathan.Cameron@huawei.com>

On Mon, Sep 04, 2023 at 02:28:03PM +0100, Jonathan Cameron wrote:

> From: Li Zhijian <lizhijian@cn.fujitsu.com>
> 
> Allocate targets and targets[n] resources when all sanity checks are
> passed to avoid memory leaks.
> 
> Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Reviewed-by: Fan Ni <fan.ni@samsung.com>

> ---
>  hw/cxl/cxl-host.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c
> index 034c7805b3..f0920da956 100644
> --- a/hw/cxl/cxl-host.c
> +++ b/hw/cxl/cxl-host.c
> @@ -39,12 +39,6 @@ static void cxl_fixed_memory_window_config(CXLState *cxl_state,
>          return;
>      }
>  
> -    fw->targets = g_malloc0_n(fw->num_targets, sizeof(*fw->targets));
> -    for (i = 0, target = object->targets; target; i++, target = target->next) {
> -        /* This link cannot be resolved yet, so stash the name for now */
> -        fw->targets[i] = g_strdup(target->value);
> -    }
> -
>      if (object->size % (256 * MiB)) {
>          error_setg(errp,
>                     "Size of a CXL fixed memory window must be a multiple of 256MiB");
> @@ -64,6 +58,12 @@ static void cxl_fixed_memory_window_config(CXLState *cxl_state,
>          fw->enc_int_gran = 0;
>      }
>  
> +    fw->targets = g_malloc0_n(fw->num_targets, sizeof(*fw->targets));
> +    for (i = 0, target = object->targets; target; i++, target = target->next) {
> +        /* This link cannot be resolved yet, so stash the name for now */
> +        fw->targets[i] = g_strdup(target->value);
> +    }
> +
>      cxl_state->fixed_windows = g_list_append(cxl_state->fixed_windows,
>                                               g_steal_pointer(&fw));
>  
> -- 
> 2.39.2
> 

  reply	other threads:[~2023-09-12 21:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 13:28 [PATCH 0/4] hw/cxl: Minor CXL emulation fixes and cleanup Jonathan Cameron via
2023-09-04 13:28 ` [PATCH 1/4] hw/cxl: Fix CFMW config memory leak Jonathan Cameron via
2023-09-12 21:22   ` Fan Ni [this message]
2023-09-13 13:59   ` Michael Tokarev
2023-09-04 13:28 ` [PATCH 2/4] hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBIS Jonathan Cameron via
2023-09-04 13:45   ` Philippe Mathieu-Daudé
2023-09-12 21:23   ` Fan Ni
2023-09-22 20:08   ` Michael Tokarev
2023-09-22 20:59     ` Dave Jiang
2023-09-04 13:28 ` [PATCH 3/4] hw/cxl/cxl_device: Replace magic number in CXLError definition Jonathan Cameron via
2023-09-04 13:46   ` Philippe Mathieu-Daudé
2023-09-04 13:28 ` [PATCH 4/4] docs/cxl: Change to lowercase as others Jonathan Cameron via
2023-09-04 13:46   ` Philippe Mathieu-Daudé
2023-09-12 21:26   ` Fan Ni
2023-09-13  6:38 ` [PATCH 0/4] hw/cxl: Minor CXL emulation fixes and cleanup Philippe Mathieu-Daudé
2023-09-13 14:00 ` Michael Tokarev

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=20230912212225.GA2859961@sjcvldevvm72 \
    --to=fan.ni@samsung.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=mst@redhat.com \
    --cc=philmd@linaro.org \
    --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).