aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2011-02-17 09:05:57 +0100
committerHannes Reinecke <hare@suse.de>2011-05-04 09:15:39 +0200
commite8cbe83c65cd0ebfd82f6889b3a8ba0d545cb77b (patch)
tree6fc4953d54fffd6b948ff4f13ccd090281bb9c9f
parent83fb936de9759b3154a8b8a0a10dde2d3209f1ec (diff)
downloadmultipath-tools-e8cbe83c65cd0ebfd82f6889b3a8ba0d545cb77b.tar.gz
libmultipath: do not access dm structures after dm_task_destroy
device-mapper has the habit of freeing up all internal structures after dm_task_destroy. So we shouldn't try to access any of these later on. References: bnc#672857 Signed-off-by: Hannes Reinecke <hare@suse.de>
-rw-r--r--libmultipath/devmapper.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 1e09333..9ee8b9e 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -941,9 +941,10 @@ dm_geteventnr (char *name)
{
struct dm_task *dmt;
struct dm_info info;
+ int event = -1;
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
- return 0;
+ return -1;
if (!dm_task_set_name(dmt, name))
goto out;
@@ -953,20 +954,16 @@ dm_geteventnr (char *name)
if (!dm_task_run(dmt))
goto out;
- if (!dm_task_get_info(dmt, &info)) {
- info.event_nr = 0;
+ if (!dm_task_get_info(dmt, &info))
goto out;
- }
- if (!info.exists) {
- info.event_nr = 0;
- goto out;
- }
+ if (info.exists)
+ event = info.event_nr;
out:
dm_task_destroy(dmt);
- return info.event_nr;
+ return event;
}
char *