Check for valid DM_DEVICE_INFO before proceeding
authorHannes Reinecke <hare@suse.de>
Wed, 23 Jul 2014 13:13:08 +0000 (15:13 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Sun, 29 Mar 2015 16:00:23 +0000 (18:00 +0200)
Calling 'DM_DEVICE_INFO' might succeed but the returned context
might refer to an invalid device. So one needs to check the 'exists'
field to avoid this.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/devmapper.c

index 5e68aeb..1901052 100644 (file)
@@ -615,6 +615,9 @@ dm_get_opencount (const char * mapname)
        if (!dm_task_get_info(dmt, &info))
                goto out;
 
+       if (!info.exists)
+               goto out;
+
        r = info.open_count;
 out:
        dm_task_destroy(dmt);
@@ -640,6 +643,9 @@ dm_get_major (char * mapname)
        if (!dm_task_get_info(dmt, &info))
                goto out;
 
+       if (!info.exists)
+               goto out;
+
        r = info.major;
 out:
        dm_task_destroy(dmt);
@@ -665,6 +671,9 @@ dm_get_minor (char * mapname)
        if (!dm_task_get_info(dmt, &info))
                goto out;
 
+       if (!info.exists)
+               goto out;
+
        r = info.minor;
 out:
        dm_task_destroy(dmt);