All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] hw/cxl: Fix CFMW config memory leak
@ 2023-05-31  6:07 Li Zhijian
  2023-05-31  7:51 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 7+ messages in thread
From: Li Zhijian @ 2023-05-31  6:07 UTC (permalink / raw)
  To: jonathan.cameron, fan.ni
  Cc: qemu-devel, Li Zhijian, Philippe Mathieu-Daudé

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>
---
V3: allocte further resource when we can't fail # Philippe
V2: Delete unnecesarry check
---
 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 034c7805b3e..f0920da956d 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.31.1





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] hw/cxl: Fix CFMW config memory leak
  2023-05-31  6:07 [PATCH v3] hw/cxl: Fix CFMW config memory leak Li Zhijian
@ 2023-05-31  7:51 ` Philippe Mathieu-Daudé
  2023-05-31 11:08   ` Jonathan Cameron via
  0 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-05-31  7:51 UTC (permalink / raw)
  To: Li Zhijian, jonathan.cameron, fan.ni; +Cc: qemu-devel

On 31/5/23 08:07, Li Zhijian wrote:
> 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>
> ---
> V3: allocte further resource when we can't fail # Philippe

Thanks for the v3!

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> V2: Delete unnecesarry check
> ---
>   hw/cxl/cxl-host.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] hw/cxl: Fix CFMW config memory leak
  2023-05-31  7:51 ` Philippe Mathieu-Daudé
@ 2023-05-31 11:08   ` Jonathan Cameron via
  2023-08-05  5:46     ` Michael Tokarev
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron via @ 2023-05-31 11:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Li Zhijian, fan.ni, qemu-devel

On Wed, 31 May 2023 09:51:43 +0200
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> On 31/5/23 08:07, Li Zhijian wrote:
> > 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>
> > ---
> > V3: allocte further resource when we can't fail # Philippe  
> 
> Thanks for the v3!
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Thanks.  I've added this near the top of my queue so will send
it out along with other similar fixes as a series for Michael
to consider picking up.

Jonathan

> 
> > V2: Delete unnecesarry check
> > ---
> >   hw/cxl/cxl-host.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)  
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] hw/cxl: Fix CFMW config memory leak
  2023-05-31 11:08   ` Jonathan Cameron via
@ 2023-08-05  5:46     ` Michael Tokarev
  2023-08-08 14:44       ` Jonathan Cameron via
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Tokarev @ 2023-08-05  5:46 UTC (permalink / raw)
  To: Jonathan Cameron, Philippe Mathieu-Daudé
  Cc: Li Zhijian, fan.ni, qemu-devel

31.05.2023 14:08, Jonathan Cameron via wrote:
> On Wed, 31 May 2023 09:51:43 +0200
> Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> 
>> On 31/5/23 08:07, Li Zhijian wrote:
>>> 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>
>>> ---
>>> V3: allocte further resource when we can't fail # Philippe
>>
>> Thanks for the v3!
>>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
> Thanks.  I've added this near the top of my queue so will send
> it out along with other similar fixes as a series for Michael
> to consider picking up.

Hi!

Has this been forgotten? Is it still needed?

/mjt


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] hw/cxl: Fix CFMW config memory leak
  2023-08-05  5:46     ` Michael Tokarev
@ 2023-08-08 14:44       ` Jonathan Cameron via
  2023-09-08 17:02         ` Michael Tokarev
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron via @ 2023-08-08 14:44 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: Philippe Mathieu-Daudé, Li Zhijian, fan.ni, qemu-devel

On Sat, 5 Aug 2023 08:46:29 +0300
Michael Tokarev <mjt@tls.msk.ru> wrote:

> 31.05.2023 14:08, Jonathan Cameron via wrote:
> > On Wed, 31 May 2023 09:51:43 +0200
> > Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> >   
> >> On 31/5/23 08:07, Li Zhijian wrote:  
> >>> 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>
> >>> ---
> >>> V3: allocte further resource when we can't fail # Philippe  
> >>
> >> Thanks for the v3!
> >>
> >> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>  
> > 
> > Thanks.  I've added this near the top of my queue so will send
> > it out along with other similar fixes as a series for Michael
> > to consider picking up.  
> 
> Hi!
> 
> Has this been forgotten? Is it still needed?
> 
> /mjt
> 

Sorry, I'm running a bit behind.  Have this one a few other fixes
still queued up - I didn't consider any of them particularly critical
for the release so wasn't rushing.

I'll aim to get them out as a series soon though so they are
available for start of next cycle if not for slipping in before
the release.

Jonathan


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] hw/cxl: Fix CFMW config memory leak
  2023-08-08 14:44       ` Jonathan Cameron via
@ 2023-09-08 17:02         ` Michael Tokarev
  2023-09-11  9:18           ` Jonathan Cameron via
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Tokarev @ 2023-09-08 17:02 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Philippe Mathieu-Daudé, Li Zhijian, fan.ni, qemu-devel, qemu-stable

08.08.2023 17:44, Jonathan Cameron:

> Sorry, I'm running a bit behind.  Have this one a few other fixes
> still queued up - I didn't consider any of them particularly critical
> for the release so wasn't rushing.
> 
> I'll aim to get them out as a series soon though so they are
> available for start of next cycle if not for slipping in before
> the release.

A month later, friendly ping? :)
(this is sent to -stable too, fwiw).

/mjt



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] hw/cxl: Fix CFMW config memory leak
  2023-09-08 17:02         ` Michael Tokarev
@ 2023-09-11  9:18           ` Jonathan Cameron via
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron via @ 2023-09-11  9:18 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: Philippe Mathieu-Daudé,
	Li Zhijian, fan.ni, qemu-devel, qemu-stable, Michael Tsirkin

On Fri, 8 Sep 2023 20:02:41 +0300
Michael Tokarev <mjt@tls.msk.ru> wrote:

> 08.08.2023 17:44, Jonathan Cameron:
> 
> > Sorry, I'm running a bit behind.  Have this one a few other fixes
> > still queued up - I didn't consider any of them particularly critical
> > for the release so wasn't rushing.
> > 
> > I'll aim to get them out as a series soon though so they are
> > available for start of next cycle if not for slipping in before
> > the release.  
> 
> A month later, friendly ping? :)
> (this is sent to -stable too, fwiw).

https://lore.kernel.org/qemu-devel/20230904132806.6094-2-Jonathan.Cameron@huawei.com/

Posted a series with this in last week.  Hopefully Michael will queue this
in his next pull.

Jonathan
> 
> /mjt
> 
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-11  9:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31  6:07 [PATCH v3] hw/cxl: Fix CFMW config memory leak Li Zhijian
2023-05-31  7:51 ` Philippe Mathieu-Daudé
2023-05-31 11:08   ` Jonathan Cameron via
2023-08-05  5:46     ` Michael Tokarev
2023-08-08 14:44       ` Jonathan Cameron via
2023-09-08 17:02         ` Michael Tokarev
2023-09-11  9:18           ` Jonathan Cameron via

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.