[PATCH 34/78] Check for valid DM_DEVICE_INFO before proceeding

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

 



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@xxxxxxx>
---
 libmultipath/devmapper.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 5e68aeb..1901052 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -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);
-- 
1.8.4.5

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux