]> xenbits.xensource.com Git - libvirt.git/commitdiff
udev_device_get_devpath might return NULL
authorGuido Günther <agx@sigxcpu.org>
Mon, 7 Dec 2009 18:00:11 +0000 (19:00 +0100)
committerGuido Günther <agx@sigxcpu.org>
Tue, 8 Dec 2009 11:01:27 +0000 (12:01 +0100)
Fix crash on strdup in that case.

src/node_device/node_device_udev.c

index 9b48052929be4ec6c2952807e7b4da24dcd1b71d..c7238fc5f848a1c4362bd9ac9d0f770c63305560 100644 (file)
@@ -947,8 +947,14 @@ static int udevProcessStorage(struct udev_device *device,
 {
     union _virNodeDevCapData *data = &def->caps->data;
     int ret = -1;
+    const char* devnode;
 
-    data->storage.block = strdup(udev_device_get_devnode(device));
+    devnode = udev_device_get_devnode(device);
+    if(!devnode) {
+        VIR_DEBUG("No devnode for '%s'\n", udev_device_get_devpath(device));
+        goto out;
+    }
+    data->storage.block = strdup(devnode);
     if (udevGetStringProperty(device,
                               "DEVNAME",
                               &data->storage.block) == PROPERTY_ERROR) {