All of lore.kernel.org
 help / color / mirror / Atom feed
From: tang.wenji@zte.com.cn
To: christophe varoqui <christophe.varoqui@free.fr>
Cc: zhang.kai16@zte.com.cn, dm-devel@redhat.com,
	tang.junhui@zte.com.cn, tang.wenji@zte.com.cn
Subject: [PATCH] mpathpersistent: segment faulty occured in mpath_persistent_reserve_in()
Date: Thu, 27 Oct 2016 16:55:28 +0800	[thread overview]
Message-ID: <1477558528-9416-1-git-send-email-tang.wenji@zte.com.cn> (raw)

From: 10111224 <tang.wenji@zte.com.cn>

Segment faulty occured when executing "mpathpersist -i -k
/dev/mapper/mpath1" command.The reason is that an uninitialized global variable conf is used in mpath_persistent_reserve_in(). The same problem also exists in
mpath_persistent_reserve_out().

Signed-off-by: tang.wenji <tang.wenji@zte.com.cn>
---
 libmpathpersist/mpath_persist.c | 21 +++++++++++++++++++--
 libmpathpersist/mpathpr.h       |  4 ----
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 7501651..582d4ef 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -78,6 +78,7 @@ updatepaths (struct multipath * mpp)
 	int i, j;
 	struct pathgroup * pgp;
 	struct path * pp;
+	struct config *conf;
 
 	if (!mpp->pg)
 		return 0;
@@ -97,16 +98,24 @@ updatepaths (struct multipath * mpp)
 					continue;
 				}
 				pp->mpp = mpp;
+				conf = get_multipath_config();
 				pathinfo(pp, conf, DI_ALL);
+				put_multipath_config(conf);
 				continue;
 			}
 			pp->mpp = mpp;
 			if (pp->state == PATH_UNCHECKED ||
-					pp->state == PATH_WILD)
+					pp->state == PATH_WILD){
+				conf = get_multipath_config();
 				pathinfo(pp, conf, DI_CHECKER);
+				put_multipath_config(conf);
+			}
 
-			if (pp->priority == PRIO_UNDEF)
+			if (pp->priority == PRIO_UNDEF){
+				conf = get_multipath_config();
 				pathinfo(pp, conf, DI_PRIO);
+				put_multipath_config(conf);
+			}
 		}
 	}
 	return 0;
@@ -159,8 +168,11 @@ int mpath_persistent_reserve_in (int fd, int rq_servact,
 	int map_present;
 	int major, minor;
 	int ret;
+	struct config *conf;
 
+	conf = get_multipath_config();
 	conf->verbosity = verbose;
+	put_multipath_config( conf);
 
 	if (fstat( fd, &info) != 0){
 		condlog(0, "stat error %d", fd);
@@ -252,8 +264,11 @@ int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
 	int j;
 	unsigned char *keyp;
 	uint64_t prkey;
+	struct config *conf;
 
+	conf = get_multipath_config();
 	conf->verbosity = verbose;
+	put_multipath_config(conf);
 
 	if (fstat( fd, &info) != 0){
 		condlog(0, "stat error fd=%d", fd);
@@ -320,7 +335,9 @@ int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
 		goto out1;
 	}
 
+	conf = get_multipath_config();
 	select_reservation_key(conf, mpp);
+	put_multipath_config(conf);
 
 	switch(rq_servact)
 	{
diff --git a/libmpathpersist/mpathpr.h b/libmpathpersist/mpathpr.h
index cd58201..e6c2ded 100644
--- a/libmpathpersist/mpathpr.h
+++ b/libmpathpersist/mpathpr.h
@@ -25,10 +25,6 @@ struct threadinfo {
 	struct prout_param param;
 };
 
-
-struct config * conf;
-
-
 int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp * resp, int noisy);
 int prout_do_scsi_ioctl( char * dev, int rq_servact, int rq_scope,
 		unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy);
-- 
2.8.1.windows.1

             reply	other threads:[~2016-10-27  8:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27  8:55 tang.wenji [this message]
2016-11-01  3:33 ` [PATCH] mpathpersistent: segment faulty occured in mpath_persistent_reserve_in() tang.junhui
2016-11-04 16:23 ` Benjamin Marzinski
2016-11-04 16:35   ` Christophe Varoqui
2016-11-07  6:35 tang.wenji
2016-11-20  9:13 ` Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477558528-9416-1-git-send-email-tang.wenji@zte.com.cn \
    --to=tang.wenji@zte.com.cn \
    --cc=christophe.varoqui@free.fr \
    --cc=dm-devel@redhat.com \
    --cc=tang.junhui@zte.com.cn \
    --cc=zhang.kai16@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.