From: Guido Günther Date: Mon, 7 Dec 2009 18:00:11 +0000 (+0100) Subject: udev_device_get_devpath might return NULL X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1f60411686b601039ad669f7aa285fa49893ac3d;p=libvirt.git udev_device_get_devpath might return NULL Fix crash on strdup in that case. --- diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 9b48052929..c7238fc5f8 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -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) {