Skip to contentSkip to conversation

libxl: get_reaper_lock_and_uid: Document fd handling

PATCH In review Ian Jackson 3 participants 3 messages Jan 2, 2019 – Jan 7, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: get_reaper_lock_and_uid: Document fd handling

Coverity understandably complains that get_reaper_lock_and_uid leaks the fd and hence open-file. But this is intentional: the lock becomes owned by the child process as a whole, which is entirely the property of libxl.

(The coding style here in this subprocess is a bit anomalous but it's probably not worth it to convert get_reaper_lock_and_uid to `goto out' style and have it explicitly return the fd number.)

---
 tools/libxl/libxl_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_dm.c +1 -1
index be493cf9f2..5de3fc7a67 100644
@@ -2889,7 +2889,7 @@ static int get_reaper_lock_and_uid(libxl__destroy_devicemodel_state *ddms,
     int domid = ddms->domid;
     int r;
     const char * lockfile;
-    int fd;
+    int fd; /* "leaked" into the general process context (even on failure) */
 
     /* Try to lock the "reaper uid" */
     lockfile = GCSPRINTF("%s/dm-reaper-lock", libxl__run_dir_path());
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ian Jackson

Coverity understandably complains that get_reaper_lock_and_uid leaks the fd and hence open-file. But this is intentional: the lock becomes owned by the child process as a whole, which is entirely the property of libxl.

(The coding style here in this subprocess is a bit anomalous but it's probably not worth it to convert get_reaper_lock_and_uid to `goto out' style and have it explicitly return the fd number.)

Coverity-ID: XXXX here?

Quoted 1 line

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/1
#2 lore raw
In reply to Ian Jackson
Quoted 9 lines · Ian Jackson

Coverity understandably complains that get_reaper_lock_and_uid leaks the fd and hence open-file. But this is intentional: the lock becomes owned by the child process as a whole, which is entirely the property of libxl.

Quoted 5 lines

(The coding style here in this subprocess is a bit anomalous but it's probably not worth it to convert get_reaper_lock_and_uid to `goto out' style and have it explicitly return the fd number.)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel