Skip to contentSkip to conversation

libxl: Set rc on failure of usbdev_busaddr_to_busid

PATCH In review Ian Jackson 2 participants 8 messages Apr 4, 2016 – Apr 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libxl: Set rc on failure of usbdev_busaddr_to_busid

We must set rc before using `goto out'.

Bug introduced in bf7628f0 "libxl: add pvusb API".

CID: 1358113

---
 tools/libxl/libxl_pvusb.c |    1 +
 1 file changed, 1 insertion(+)
tools/libxl/libxl_pvusb.c +1 -0
index 5f92628..6f53317 100644
@@ -905,6 +905,7 @@ static int libxl__device_usbdev_add_xenstore(libxl__gc *gc, uint32_t domid,
                                     usbdev->u.hostdev.hostaddr);
     if (!busid) {
         LOG(DEBUG, "Fail to get busid of usb device");
+        rc = ERROR_FAIL;
         goto out;
     }
 
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

PATCH 2/2 libxl: Do not leak data on error path from libxl__read_sysfs_file_contents

Bug introduced in bc023ecd
"libxl_utils: add internal function to read sysfs file contents"

CID: 1358108

---
 tools/libxl/libxl_utils.c |    1 +
 1 file changed, 1 insertion(+)
tools/libxl/libxl_utils.c +1 -0
index ceb8825..bd58a52 100644
@@ -466,6 +466,7 @@ int libxl__read_sysfs_file_contents(libxl__gc *gc, const char *filename,
     e = errno;
     assert(e != ENOENT);
     if (f) fclose(f);
+    free(data);
     return e;
 }
 
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH 2/2] libxl: Do not leak data on error path from libxl__read_sysfs_file_contents

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

On 4/4/2016 at 11:10 PM, in message

<[email protected]>, Ian Jackson

Quoted 16 lines · <[email protected]> wrote:

Bug introduced in bc023ecd
"libxl_utils: add internal function to read sysfs file contents"

CID: 1358108

---

 tools/libxl/libxl_utils.c |    1 + 
 1 file changed, 1 insertion(+) 
tools/libxl/libxl_utils.c +0 -0
index ceb8825..bd58a52 100644 

tools/libxl/libxl_utils.c int libxl__read_sysfs_file_contents(libxl__gc *gc, const · line 470

Quoted 5 lines
tools/libxl/libxl_utils.c +1 -0
@@ -466,6 +466,7 @@ int libxl__read_sysfs_file_contents(libxl__gc *gc, const  
 char *filename, 
     e = errno; 
     assert(e != ENOENT); 
     if (f) fclose(f); 
+    free(data); 

'data' is malloced with 'gc', it'll be freed by GC_FREE. Do we need to free it here?

Chunyan

tools/libxl/libxl_utils.c int libxl__read_sysfs_file_contents(libxl__gc *gc, const char *filename, · line 471

Quoted 3 lines
tools/libxl/libxl_utils.c +0 -0
     return e; 
 } 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH 2/2] libxl: Do not leak data on error path from libxl__read_sysfs_file_contents

Chun Yan Liu writes ("Re: [PATCH 2/2] libxl: Do not leak data on error path from libxl__read_sysfs_file_contents"):

Quoted 6 lines

<[email protected]>, Ian Jackson

Quoted 1 line · <[email protected]> wrote:

+ free(data);

'data' is malloced with 'gc', it'll be freed by GC_FREE. Do we need to free it here?

Oh, you are quite right. My patch was wrong.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
In reply to Ian Jackson

Thanks, Ian!

Quoted 1 line
Quoted 1 line
Quoted 1 line

On 4/4/2016 at 11:09 PM, in message

<[email protected]>, Ian Jackson

Quoted 20 lines · <[email protected]> wrote:

We must set rc before using `goto out'.

Bug introduced in bf7628f0 "libxl: add pvusb API".

CID: 1358113

---

 tools/libxl/libxl_pvusb.c |    1 + 
 1 file changed, 1 insertion(+) 
tools/libxl/libxl_pvusb.c +0 -0
index 5f92628..6f53317 100644 

tools/libxl/libxl_pvusb.c static int libxl__device_usbdev_add_xenstore(libxl__gc · line 911

Quoted 7 lines
tools/libxl/libxl_pvusb.c +1 -0
@@ -905,6 +905,7 @@ static int libxl__device_usbdev_add_xenstore(libxl__gc  
 *gc, uint32_t domid, 
                                     usbdev->u.hostdev.hostaddr); 
     if (!busid) { 
         LOG(DEBUG, "Fail to get busid of usb device"); 
+        rc = ERROR_FAIL; 
         goto out; 
     } 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

On 4/8/2016 at 01:04 AM, in message

<[email protected]>, Ian Jackson

Quoted 5 lines · <[email protected]> wrote:

Chun Yan Liu writes ("Re: [PATCH 1/2] libxl: Set rc on failure of usbdev_busaddr_to_busid"):

Quoted 1 line

Thanks, Ian!

Should I take that as a Reviewed-by ?

Ah, yes. Acked. :-)

Chunyan

Quoted 5 lines

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw

Chun Yan Liu writes ("Re: [PATCH 1/2] libxl: Set rc on failure of usbdev_busaddr_to_busid"):

Quoted 10 lines
Quoted 5 lines · Ian Jackson

Chun Yan Liu writes ("Re: [PATCH 1/2] libxl: Set rc on failure of usbdev_busaddr_to_busid"):

Quoted 1 line

Thanks, Ian!

Should I take that as a Reviewed-by ?

Ah, yes. Acked. :-)

Thanks, queued.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel