summaryrefslogtreecommitdiffstats
path: root/discover/udev.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-10-09 16:38:56 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-10-09 17:22:46 +0800
commit1c1f5e06ba16a383331a5756aa856daba8169ed8 (patch)
tree8b0bb2be392ea79020bbaf540d113327c1e07c39 /discover/udev.c
parent96eedc649c8c0909a564787afebcfbe0588fd651 (diff)
downloadtalos-petitboot-1c1f5e06ba16a383331a5756aa856daba8169ed8.tar.gz
talos-petitboot-1c1f5e06ba16a383331a5756aa856daba8169ed8.zip
discover/udev: dup property values returned from udev
The property strings are managed by the udev code, so we need to strdup. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/udev.c')
-rw-r--r--discover/udev.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/discover/udev.c b/discover/udev.c
index e996e22..6212e43 100644
--- a/discover/udev.c
+++ b/discover/udev.c
@@ -73,6 +73,7 @@ static int udev_handle_dev_add(struct pb_udev *udev, struct udev_device *dev)
const char *serial;
const char *path;
const char *name;
+ const char *prop;
name = udev_device_get_sysname(dev);
if (!name) {
@@ -114,8 +115,12 @@ static int udev_handle_dev_add(struct pb_udev *udev, struct udev_device *dev)
ddev = discover_device_create(udev->handler, name);
ddev->device_path = udev_device_get_devnode(dev);
- ddev->uuid = udev_device_get_property_value(dev, "ID_FS_UUID");
- ddev->label = udev_device_get_property_value(dev, "ID_FS_LABEL");
+ prop = udev_device_get_property_value(dev, "ID_FS_UUID");
+ if (prop)
+ ddev->uuid = talloc_strdup(ddev, prop);
+ prop = udev_device_get_property_value(dev, "ID_FS_LABEL");
+ if (prop)
+ ddev->label = talloc_strdup(ddev, prop);
ddev->device->type = DEVICE_TYPE_DISK;
udev_setup_device_params(dev, ddev);
OpenPOWER on IntegriCloud