discover/udev: copy dev->device path from udev devnode
authorJeremy Kerr <jk@ozlabs.org>
Fri, 29 Nov 2013 05:44:54 +0000 (13:44 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 2 Dec 2013 04:05:13 +0000 (12:05 +0800)
We're seeing a use-after-free, as the udev path is freed before the
discover device.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/udev.c

index 48ab745b4f371ac410048dc3ab7b93f9dc3ff4fb..5aa2898b0e55ffdb18a59f802e3e6100ed8fbe88 100644 (file)
@@ -105,7 +105,8 @@ 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->device_path = talloc_strdup(ddev, udev_device_get_devnode(dev));
+
        prop = udev_device_get_property_value(dev, "ID_FS_UUID");
        if (prop)
                ddev->uuid = talloc_strdup(ddev, prop);