From: Hannes Reinecke Date: Thu, 17 Feb 2011 08:05:57 +0000 (+0100) Subject: libmultipath: do not access dm structures after dm_task_destroy X-Git-Tag: upstream/0.5.0~106^2~56 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e8cbe83c65cd0ebfd82f6889b3a8ba0d545cb77b;p=platform%2Fupstream%2Fmultipath-tools.git 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 --- 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 *