All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxl: do not call exit() in libxl_device_vtpm_list
@ 2013-05-08  3:47 Marek Marczykowski
  2013-05-08  5:28 ` Jim Fehlig
  2013-05-08  9:35 ` Ian Campbell
  0 siblings, 2 replies; 4+ messages in thread
From: Marek Marczykowski @ 2013-05-08  3:47 UTC (permalink / raw)
  To: xen-devel; +Cc: Marek Marczykowski, Ian Campbell

Signal error with NULL return value, do not terminate the whole process.

Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com>
---
 tools/libxl/libxl.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 03fd35a..5b9a3df 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1860,11 +1860,12 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n
           vtpm->backend_domid = atoi(tmp);
 
           tmp = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/uuid", be_path));
-          if(tmp) {
-             if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
-                LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
-                exit(1);
-             }
+          if (tmp) {
+              if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
+                  LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
+                  free(vtpms);
+                  return NULL;
+              }
           }
        }
     }
-- 
1.8.1.4

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

* Re: [PATCH] libxl: do not call exit() in libxl_device_vtpm_list
  2013-05-08  3:47 [PATCH] libxl: do not call exit() in libxl_device_vtpm_list Marek Marczykowski
@ 2013-05-08  5:28 ` Jim Fehlig
  2013-05-08  9:35 ` Ian Campbell
  1 sibling, 0 replies; 4+ messages in thread
From: Jim Fehlig @ 2013-05-08  5:28 UTC (permalink / raw)
  To: Marek Marczykowski; +Cc: Ian Campbell, xen-devel

Marek Marczykowski wrote:
> Signal error with NULL return value, do not terminate the whole process.
>
> Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com>
> ---
>  tools/libxl/libxl.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 03fd35a..5b9a3df 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -1860,11 +1860,12 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n
>            vtpm->backend_domid = atoi(tmp);
>  
>            tmp = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/uuid", be_path));
> -          if(tmp) {
> -             if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
> -                LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
> -                exit(1);
> -             }
>   

Ouch.  libxl shouldn't be calling exit :).

> +          if (tmp) {
> +              if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
> +                  LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
> +                  free(vtpms);
> +                  return NULL;
> +              }
>            }
>         }
>      }
>   

    Reviewed-by: Jim Fehlig <jfehlig@suse.com>

Regards,
Jim

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

* Re: [PATCH] libxl: do not call exit() in libxl_device_vtpm_list
  2013-05-08  3:47 [PATCH] libxl: do not call exit() in libxl_device_vtpm_list Marek Marczykowski
  2013-05-08  5:28 ` Jim Fehlig
@ 2013-05-08  9:35 ` Ian Campbell
  2013-07-04 10:41   ` Ian Campbell
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2013-05-08  9:35 UTC (permalink / raw)
  To: Marek Marczykowski; +Cc: xen-devel@lists.xen.org

On Wed, 2013-05-08 at 04:47 +0100, Marek Marczykowski wrote:
> Signal error with NULL return value, do not terminate the whole process.

Ouch! Good catch.

> Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com>
> ---
>  tools/libxl/libxl.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 03fd35a..5b9a3df 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -1860,11 +1860,12 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n
>            vtpm->backend_domid = atoi(tmp);
>  
>            tmp = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/uuid", be_path));
> -          if(tmp) {
> -             if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
> -                LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
> -                exit(1);
> -             }
> +          if (tmp) {
> +              if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
> +                  LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
> +                  free(vtpms);

I think this also needs to libxl_device_vtpm_dispose any prior entries
in the array. libxl_device_vtpm_list_free() should be helpful here.

> +                  return NULL;
> +              }
>            }
>         }
>      }

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

* Re: [PATCH] libxl: do not call exit() in libxl_device_vtpm_list
  2013-05-08  9:35 ` Ian Campbell
@ 2013-07-04 10:41   ` Ian Campbell
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2013-07-04 10:41 UTC (permalink / raw)
  To: Marek Marczykowski
  Cc: George Dunlap, Daniel De Graaf, Ian Jackson, Jan Beulich,
	xen-devel@lists.xen.org

On Wed, 2013-05-08 at 10:35 +0100, Ian Campbell wrote:
> On Wed, 2013-05-08 at 04:47 +0100, Marek Marczykowski wrote:
> > Signal error with NULL return value, do not terminate the whole process.
> 
> Ouch! Good catch.
> 
> > Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com>

I've applied this to staging. Is anyone able to take care of the memory
leak I mentioned below?

I think this should go into 4.3.1 if not 4.3.0.

> > ---
> >  tools/libxl/libxl.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> > index 03fd35a..5b9a3df 100644
> > --- a/tools/libxl/libxl.c
> > +++ b/tools/libxl/libxl.c
> > @@ -1860,11 +1860,12 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n
> >            vtpm->backend_domid = atoi(tmp);
> >  
> >            tmp = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/uuid", be_path));
> > -          if(tmp) {
> > -             if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
> > -                LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
> > -                exit(1);
> > -             }
> > +          if (tmp) {
> > +              if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
> > +                  LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
> > +                  free(vtpms);
> 
> I think this also needs to libxl_device_vtpm_dispose any prior entries
> in the array. libxl_device_vtpm_list_free() should be helpful here.
> 
> > +                  return NULL;
> > +              }
> >            }
> >         }
> >      }
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2013-07-04 10:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-08  3:47 [PATCH] libxl: do not call exit() in libxl_device_vtpm_list Marek Marczykowski
2013-05-08  5:28 ` Jim Fehlig
2013-05-08  9:35 ` Ian Campbell
2013-07-04 10:41   ` Ian Campbell

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.