discover: Allow devices with no device_path
authorJeremy Kerr <jk@ozlabs.org>
Mon, 13 May 2013 02:08:47 +0000 (10:08 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 15 May 2013 06:50:25 +0000 (14:50 +0800)
Devices that have been added via the user path may not have a device
path. In this case, don't segfault in device_match_path, and break out
of mount_device early.

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

index 43171eb7e1d7f0e2f6ec95392d364597dfa8c1cf..23961249ff595b857b327a34f025e31c64a97d1d 100644 (file)
@@ -235,6 +235,9 @@ static int mount_device(struct discover_device *dev)
 {
        const char *argv[6];
 
 {
        const char *argv[6];
 
+       if (!dev->device_path)
+               return -1;
+
        if (!dev->mount_path)
                dev->mount_path = join_paths(dev, mount_base(),
                                                dev->device_path);
        if (!dev->mount_path)
                dev->mount_path = join_paths(dev, mount_base(),
                                                dev->device_path);
@@ -576,7 +579,7 @@ void device_handler_destroy(struct device_handler *handler)
 
 static int device_match_path(struct discover_device *dev, const char *path)
 {
 
 static int device_match_path(struct discover_device *dev, const char *path)
 {
-       return !strcmp(dev->device_path, path);
+       return dev->device_path && !strcmp(dev->device_path, path);
 }
 
 static int device_match_uuid(struct discover_device *dev, const char *uuid)
 }
 
 static int device_match_uuid(struct discover_device *dev, const char *uuid)