[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] udev_device_get_devpath might return NULL



On 12/07/2009 01:15 PM, Guido Günther wrote:
Fix crash on daemon strdup in that case.

udev_device_get_devpath returs NULL for
'/sys/devices/virtual/block/dm-*' devices. In that case the later strdup
segfaults. O.k. to apply?

ACK--thanks.

Dave


19:12:46.319: info : udevGetDeviceProperty:111 : udev reports device 'dm-0' does not have property 'DRIVER'
19:12:46.319: debug : udevProcessStorage:954 : No devnode for '/devices/virtual/block/dm-0'
19:12:46.319: info : udevProcessDeviceListEntry:1261 : Failed to create node device for udev device '/sys/devices/virtual/block/dm-0'

---
  src/node_device/node_device_udev.c |    8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 9b48052..c7238fc 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) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]