Skip to contentSkip to conversation

libxl: fix printing hotplug arguments/environment

PATCH In review Roger Pau Monne 2 participants 2 messages Aug 2, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libxl: fix printing hotplug arguments/environment

An OS could decide to not pass any environment variables to hotplug scripts, and this will trigger a bug in device_hotplug logic, since it expects the environment array to exist. Allow env to be NULL.

---
Cc: Wei Liu <[email protected]>
Cc: Ian Jackson <[email protected]>
---
Changes since v1:
- Fix commit message
- Only allow env to be NULL.

---
 tools/libxl/libxl_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxl/libxl_device.c +2 -1
index b9a6df2..dbf157d 100644
@@ -1130,6 +1130,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
         goto out;
     }
 
+    assert(args != NULL);
     LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
     LOG(DEBUG, "extra args:");
     {
@@ -1140,7 +1141,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
             LOG(DEBUG, "\t%s", arg);
     }
     LOG(DEBUG, "env:");
-    {
+    if (env != NULL) {
         const char *k, *v;
         unsigned int x;
 
Signature · 7 lines
2.7.4 (Apple Git-66)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Roger Pau Monne

An OS could decide to not pass any environment variables to hotplug scripts, and this will trigger a bug in device_hotplug logic, since it expects the environment array to exist. Allow env to be NULL.

Quoted 35 lines

---
Cc: Wei Liu <[email protected]>
Cc: Ian Jackson <[email protected]>
---
Changes since v1:
- Fix commit message
- Only allow env to be NULL.

---
 tools/libxl/libxl_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxl/libxl_device.c +2 -1
index b9a6df2..dbf157d 100644
@@ -1130,6 +1130,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
         goto out;
     }
 
+    assert(args != NULL);
     LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
     LOG(DEBUG, "extra args:");
     {
@@ -1140,7 +1141,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
             LOG(DEBUG, "\t%s", arg);
     }
     LOG(DEBUG, "env:");
-    {
+    if (env != NULL) {
         const char *k, *v;
         unsigned int x;
 
Signature · 1 line
2.7.4 (Apple Git-66)

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