All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/xen: Use g_free instead of free and fix potential memory leaks
@ 2013-06-10 20:36 ` Stefan Weil
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2013-06-10 20:36 UTC (permalink / raw)
  To: qemu-trivial; +Cc: Stefan Weil, xen-devel, qemu-devel, Stefano Stabellini

The wrong functions and the missing calls of g_free were reported
by cppcheck.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/xen/xen_pt_config_init.c |    4 ++--
 xen-all.c                   |    8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index 01872db..8ccc2e4 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -1777,12 +1777,12 @@ static int xen_pt_config_reg_init(XenPCIPassthroughState *s,
         rc = reg->init(s, reg_entry->reg,
                        reg_grp->base_offset + reg->offset, &data);
         if (rc < 0) {
-            free(reg_entry);
+            g_free(reg_entry);
             return rc;
         }
         if (data == XEN_PT_INVALID_REG) {
             /* free unused BAR register entry */
-            free(reg_entry);
+            g_free(reg_entry);
             return 0;
         }
         /* set register value */
diff --git a/xen-all.c b/xen-all.c
index bc105f1..1a1d7bb 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -389,7 +389,7 @@ static int xen_remove_from_physmap(XenIOState *state,
     if (state->log_for_dirtybit == physmap) {
         state->log_for_dirtybit = NULL;
     }
-    free(physmap);
+    g_free(physmap);
 
     return 0;
 }
@@ -1030,7 +1030,7 @@ static void xen_read_physmap(XenIOState *state)
                 xen_domid, entries[i]);
         value = xs_read(state->xenstore, 0, path, &len);
         if (value == NULL) {
-            free(physmap);
+            g_free(physmap);
             continue;
         }
         physmap->start_addr = strtoull(value, NULL, 16);
@@ -1041,7 +1041,7 @@ static void xen_read_physmap(XenIOState *state)
                 xen_domid, entries[i]);
         value = xs_read(state->xenstore, 0, path, &len);
         if (value == NULL) {
-            free(physmap);
+            g_free(physmap);
             continue;
         }
         physmap->size = strtoull(value, NULL, 16);
@@ -1069,12 +1069,14 @@ int xen_hvm_init(void)
     state->xce_handle = xen_xc_evtchn_open(NULL, 0);
     if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
         perror("xen: event channel open");
+        g_free(state);
         return -errno;
     }
 
     state->xenstore = xs_daemon_open();
     if (state->xenstore == NULL) {
         perror("xen: xenstore open");
+        g_free(state);
         return -errno;
     }
 
-- 
1.7.10.4

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

* [PATCH] hw/xen: Use g_free instead of free and fix potential memory leaks
@ 2013-06-10 20:36 ` Stefan Weil
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2013-06-10 20:36 UTC (permalink / raw)
  To: qemu-trivial; +Cc: Stefan Weil, xen-devel, qemu-devel, Stefano Stabellini

The wrong functions and the missing calls of g_free were reported
by cppcheck.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/xen/xen_pt_config_init.c |    4 ++--
 xen-all.c                   |    8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index 01872db..8ccc2e4 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -1777,12 +1777,12 @@ static int xen_pt_config_reg_init(XenPCIPassthroughState *s,
         rc = reg->init(s, reg_entry->reg,
                        reg_grp->base_offset + reg->offset, &data);
         if (rc < 0) {
-            free(reg_entry);
+            g_free(reg_entry);
             return rc;
         }
         if (data == XEN_PT_INVALID_REG) {
             /* free unused BAR register entry */
-            free(reg_entry);
+            g_free(reg_entry);
             return 0;
         }
         /* set register value */
diff --git a/xen-all.c b/xen-all.c
index bc105f1..1a1d7bb 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -389,7 +389,7 @@ static int xen_remove_from_physmap(XenIOState *state,
     if (state->log_for_dirtybit == physmap) {
         state->log_for_dirtybit = NULL;
     }
-    free(physmap);
+    g_free(physmap);
 
     return 0;
 }
@@ -1030,7 +1030,7 @@ static void xen_read_physmap(XenIOState *state)
                 xen_domid, entries[i]);
         value = xs_read(state->xenstore, 0, path, &len);
         if (value == NULL) {
-            free(physmap);
+            g_free(physmap);
             continue;
         }
         physmap->start_addr = strtoull(value, NULL, 16);
@@ -1041,7 +1041,7 @@ static void xen_read_physmap(XenIOState *state)
                 xen_domid, entries[i]);
         value = xs_read(state->xenstore, 0, path, &len);
         if (value == NULL) {
-            free(physmap);
+            g_free(physmap);
             continue;
         }
         physmap->size = strtoull(value, NULL, 16);
@@ -1069,12 +1069,14 @@ int xen_hvm_init(void)
     state->xce_handle = xen_xc_evtchn_open(NULL, 0);
     if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
         perror("xen: event channel open");
+        g_free(state);
         return -errno;
     }
 
     state->xenstore = xs_daemon_open();
     if (state->xenstore == NULL) {
         perror("xen: xenstore open");
+        g_free(state);
         return -errno;
     }
 
-- 
1.7.10.4

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

* Re: [Qemu-devel] [PATCH] hw/xen: Use g_free instead of free and fix potential memory leaks
  2013-06-10 20:36 ` Stefan Weil
@ 2013-06-11 11:02   ` Stefano Stabellini
  -1 siblings, 0 replies; 6+ messages in thread
From: Stefano Stabellini @ 2013-06-11 11:02 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, xen-devel, qemu-devel, Stefano Stabellini

On Mon, 10 Jun 2013, Stefan Weil wrote:
> The wrong functions and the missing calls of g_free were reported
> by cppcheck.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Are you happy to get this patch upstream via qemu-trivial? Or do you
want me to pick it up?


>  hw/xen/xen_pt_config_init.c |    4 ++--
>  xen-all.c                   |    8 +++++---
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
> index 01872db..8ccc2e4 100644
> --- a/hw/xen/xen_pt_config_init.c
> +++ b/hw/xen/xen_pt_config_init.c
> @@ -1777,12 +1777,12 @@ static int xen_pt_config_reg_init(XenPCIPassthroughState *s,
>          rc = reg->init(s, reg_entry->reg,
>                         reg_grp->base_offset + reg->offset, &data);
>          if (rc < 0) {
> -            free(reg_entry);
> +            g_free(reg_entry);
>              return rc;
>          }
>          if (data == XEN_PT_INVALID_REG) {
>              /* free unused BAR register entry */
> -            free(reg_entry);
> +            g_free(reg_entry);
>              return 0;
>          }
>          /* set register value */
> diff --git a/xen-all.c b/xen-all.c
> index bc105f1..1a1d7bb 100644
> --- a/xen-all.c
> +++ b/xen-all.c
> @@ -389,7 +389,7 @@ static int xen_remove_from_physmap(XenIOState *state,
>      if (state->log_for_dirtybit == physmap) {
>          state->log_for_dirtybit = NULL;
>      }
> -    free(physmap);
> +    g_free(physmap);
>  
>      return 0;
>  }
> @@ -1030,7 +1030,7 @@ static void xen_read_physmap(XenIOState *state)
>                  xen_domid, entries[i]);
>          value = xs_read(state->xenstore, 0, path, &len);
>          if (value == NULL) {
> -            free(physmap);
> +            g_free(physmap);
>              continue;
>          }
>          physmap->start_addr = strtoull(value, NULL, 16);
> @@ -1041,7 +1041,7 @@ static void xen_read_physmap(XenIOState *state)
>                  xen_domid, entries[i]);
>          value = xs_read(state->xenstore, 0, path, &len);
>          if (value == NULL) {
> -            free(physmap);
> +            g_free(physmap);
>              continue;
>          }
>          physmap->size = strtoull(value, NULL, 16);
> @@ -1069,12 +1069,14 @@ int xen_hvm_init(void)
>      state->xce_handle = xen_xc_evtchn_open(NULL, 0);
>      if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
>          perror("xen: event channel open");
> +        g_free(state);
>          return -errno;
>      }
>  
>      state->xenstore = xs_daemon_open();
>      if (state->xenstore == NULL) {
>          perror("xen: xenstore open");
> +        g_free(state);
>          return -errno;
>      }
>  
> -- 
> 1.7.10.4
> 

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

* Re: [PATCH] hw/xen: Use g_free instead of free and fix potential memory leaks
@ 2013-06-11 11:02   ` Stefano Stabellini
  0 siblings, 0 replies; 6+ messages in thread
From: Stefano Stabellini @ 2013-06-11 11:02 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, xen-devel, qemu-devel, Stefano Stabellini

On Mon, 10 Jun 2013, Stefan Weil wrote:
> The wrong functions and the missing calls of g_free were reported
> by cppcheck.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Are you happy to get this patch upstream via qemu-trivial? Or do you
want me to pick it up?


>  hw/xen/xen_pt_config_init.c |    4 ++--
>  xen-all.c                   |    8 +++++---
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
> index 01872db..8ccc2e4 100644
> --- a/hw/xen/xen_pt_config_init.c
> +++ b/hw/xen/xen_pt_config_init.c
> @@ -1777,12 +1777,12 @@ static int xen_pt_config_reg_init(XenPCIPassthroughState *s,
>          rc = reg->init(s, reg_entry->reg,
>                         reg_grp->base_offset + reg->offset, &data);
>          if (rc < 0) {
> -            free(reg_entry);
> +            g_free(reg_entry);
>              return rc;
>          }
>          if (data == XEN_PT_INVALID_REG) {
>              /* free unused BAR register entry */
> -            free(reg_entry);
> +            g_free(reg_entry);
>              return 0;
>          }
>          /* set register value */
> diff --git a/xen-all.c b/xen-all.c
> index bc105f1..1a1d7bb 100644
> --- a/xen-all.c
> +++ b/xen-all.c
> @@ -389,7 +389,7 @@ static int xen_remove_from_physmap(XenIOState *state,
>      if (state->log_for_dirtybit == physmap) {
>          state->log_for_dirtybit = NULL;
>      }
> -    free(physmap);
> +    g_free(physmap);
>  
>      return 0;
>  }
> @@ -1030,7 +1030,7 @@ static void xen_read_physmap(XenIOState *state)
>                  xen_domid, entries[i]);
>          value = xs_read(state->xenstore, 0, path, &len);
>          if (value == NULL) {
> -            free(physmap);
> +            g_free(physmap);
>              continue;
>          }
>          physmap->start_addr = strtoull(value, NULL, 16);
> @@ -1041,7 +1041,7 @@ static void xen_read_physmap(XenIOState *state)
>                  xen_domid, entries[i]);
>          value = xs_read(state->xenstore, 0, path, &len);
>          if (value == NULL) {
> -            free(physmap);
> +            g_free(physmap);
>              continue;
>          }
>          physmap->size = strtoull(value, NULL, 16);
> @@ -1069,12 +1069,14 @@ int xen_hvm_init(void)
>      state->xce_handle = xen_xc_evtchn_open(NULL, 0);
>      if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
>          perror("xen: event channel open");
> +        g_free(state);
>          return -errno;
>      }
>  
>      state->xenstore = xs_daemon_open();
>      if (state->xenstore == NULL) {
>          perror("xen: xenstore open");
> +        g_free(state);
>          return -errno;
>      }
>  
> -- 
> 1.7.10.4
> 

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

* Re: [Qemu-devel] [PATCH] hw/xen: Use g_free instead of free and fix potential memory leaks
  2013-06-11 11:02   ` Stefano Stabellini
@ 2013-06-11 17:37     ` Stefan Weil
  -1 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2013-06-11 17:37 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: qemu-trivial, xen-devel, qemu-devel

Am 11.06.2013 13:02, schrieb Stefano Stabellini:
> On Mon, 10 Jun 2013, Stefan Weil wrote:
>> The wrong functions and the missing calls of g_free were reported
>> by cppcheck.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>
> Are you happy to get this patch upstream via qemu-trivial? Or do you
> want me to pick it up?

Thank you for the review.

qemu-trivial is fine, and Michael already applied the patch.

Regards
Stefan

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

* Re: [PATCH] hw/xen: Use g_free instead of free and fix potential memory leaks
@ 2013-06-11 17:37     ` Stefan Weil
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2013-06-11 17:37 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: qemu-trivial, xen-devel, qemu-devel

Am 11.06.2013 13:02, schrieb Stefano Stabellini:
> On Mon, 10 Jun 2013, Stefan Weil wrote:
>> The wrong functions and the missing calls of g_free were reported
>> by cppcheck.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>
> Are you happy to get this patch upstream via qemu-trivial? Or do you
> want me to pick it up?

Thank you for the review.

qemu-trivial is fine, and Michael already applied the patch.

Regards
Stefan

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

end of thread, other threads:[~2013-06-11 17:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-10 20:36 [Qemu-devel] [PATCH] hw/xen: Use g_free instead of free and fix potential memory leaks Stefan Weil
2013-06-10 20:36 ` Stefan Weil
2013-06-11 11:02 ` [Qemu-devel] " Stefano Stabellini
2013-06-11 11:02   ` Stefano Stabellini
2013-06-11 17:37   ` [Qemu-devel] " Stefan Weil
2013-06-11 17:37     ` Stefan Weil

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.