libxl: do not call exit() in libxl_device_vtpm_list
PATCH 1/1 libxl: do not call exit() in libxl_device_vtpm_list
Signal error with NULL return value, do not terminate the whole process.
--- tools/libxl/libxl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +6 -5
@@ -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 ; + } } } }
Signature · 1 line
1.8.1.4
Quoted 12 lines · Marek Marczykowski
Signal error with NULL return value, do not terminate the whole process.
Signed-off-by Marek Marczykowski <[email protected]>--- tools/libxl/libxl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)tools/libxl/libxl.c +0
-0
tools/libxl/libxl.c libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n · line 1863
Quoted 9 lines
tools/libxl/libxl.c +0
-5@@ -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 :).
Quoted 10 lines
tools/libxl/libxl.c +6
-0+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 ; + } } }}
Regards,
Jim
Quoted 1 line · Marek Marczykowski
Signal error with NULL return value, do not terminate the whole process.
Ouch! Good catch.
Quoted 12 lines
Signed-off-by Marek Marczykowski <[email protected]>--- tools/libxl/libxl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)tools/libxl/libxl.c +0
-0@@ -1860,11 +1860,12 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n vtpm->backend_domid =atoi (tmp);
tools/libxl/libxl.c libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n · line 1866
Quoted 10 lines
tools/libxl/libxl.c +4
-5tmp =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.
Quoted 5 lines
tools/libxl/libxl.c +2
-0+return NULL ; + } } } }
Quoted 6 lines · Ian Campbell
Quoted 1 line · Marek Marczykowski
Signal error with NULL return value, do not terminate the whole process.
Ouch! Good catch.
Quoted 1 line
Signed-off-by Marek Marczykowski <[email protected]>
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.
Quoted 37 lines
Quoted 11 lines
--- tools/libxl/libxl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)tools/libxl/libxl.c +0
-0@@ -1860,11 +1860,12 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n vtpm->backend_domid =atoi (tmp);tools/libxl/libxl.c libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n · line 1866
Quoted 10 lines
tools/libxl/libxl.c +4
-5tmp =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_disposeany prior entries in the array.libxl_device_vtpm_list_free()should be helpful here.tools/libxl/libxl.c libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n · line 1871
Quoted 5 lines
tools/libxl/libxl.c +2
-0+return NULL ; + } } } }_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel