Blame SOURCES/0268-RHBZ-1721855-mpathpersist-fixes.patch

4728c8
---
958de5
 libmpathpersist/mpath_persist.c |    2 +-
958de5
 mpathpersist/main.c             |   36 ++++++++++++++++++++++--------------
958de5
 2 files changed, 23 insertions(+), 15 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/mpathpersist/main.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/mpathpersist/main.c
4728c8
+++ multipath-tools-130222/mpathpersist/main.c
4728c8
@@ -141,7 +141,8 @@ static int do_batch_file(const char *bat
4728c8
 
4728c8
 static int handle_args(int argc, char * argv[], int nline)
4728c8
 {
4728c8
-	int fd, c;
4728c8
+	int c;
4728c8
+	int fd = -1;
4728c8
 	const char *device_name = NULL;
4728c8
 	int num_prin_sa = 0;
4728c8
 	int num_prout_sa = 0;
4728c8
@@ -199,7 +200,8 @@ static int handle_args(int argc, char *
4728c8
 				if (nline == 0 && 1 != sscanf (optarg, "%d", &loglevel))
4728c8
 				{
4728c8
 					fprintf (stderr, "bad argument to '--verbose'\n");
4728c8
-					return MPATH_PR_SYNTAX_ERROR;
4728c8
+					ret = MPATH_PR_SYNTAX_ERROR;
4728c8
+					goto out;
4728c8
 				}
4728c8
 				break;
4728c8
 
4728c8
@@ -214,6 +216,7 @@ static int handle_args(int argc, char *
4728c8
 
4728c8
 			case 'h':
4728c8
 				usage ();
4728c8
+				free(batch_fn);
4728c8
 				return 0;
4728c8
 
4728c8
 			case 'H':
4728c8
@@ -236,7 +239,8 @@ static int handle_args(int argc, char *
4728c8
 				if (parse_prkey(optarg, &param_rk) != 0)
4728c8
 				{
4728c8
 					fprintf (stderr, "bad argument to '--param-rk'\n");
4728c8
-					return MPATH_PR_SYNTAX_ERROR;
4728c8
+					ret = MPATH_PR_SYNTAX_ERROR;
4728c8
+					goto out;
4728c8
 				}
4728c8
 				++num_prout_param;
4728c8
 				break;
4728c8
@@ -245,7 +249,8 @@ static int handle_args(int argc, char *
4728c8
 				if (parse_prkey(optarg, &param_sark) != 0)
4728c8
 				{
4728c8
 					fprintf (stderr, "bad argument to '--param-sark'\n");
4728c8
-					return MPATH_PR_SYNTAX_ERROR;
4728c8
+					ret = MPATH_PR_SYNTAX_ERROR;
4728c8
+					goto out;
4728c8
 				}
4728c8
 				++num_prout_param;
4728c8
 				break;
4728c8
@@ -264,7 +269,8 @@ static int handle_args(int argc, char *
4728c8
 				if (1 != sscanf (optarg, "%x", &prout_type))
4728c8
 				{
4728c8
 					fprintf (stderr, "bad argument to '--prout-type'\n");
4728c8
-					return MPATH_PR_SYNTAX_ERROR;
4728c8
+					ret = MPATH_PR_SYNTAX_ERROR;
4728c8
+					goto out;
4728c8
 				}
4728c8
 				++num_prout_param;
4728c8
 				break;
4728c8
@@ -312,7 +318,8 @@ static int handle_args(int argc, char *
4728c8
 			case 'X':
4728c8
 				if (0 != construct_transportid(optarg, transportids, num_transport)) {
4728c8
 					fprintf(stderr, "bad argument to '--transport-id'\n");
4728c8
-					return MPATH_PR_SYNTAX_ERROR;
4728c8
+					ret = MPATH_PR_SYNTAX_ERROR;
4728c8
+					goto out;
4728c8
 				}
4728c8
 
4728c8
 				++num_transport;
4728c8
@@ -320,12 +327,13 @@ static int handle_args(int argc, char *
4728c8
 
4728c8
 			case 'l':
4728c8
                                 if (1 != sscanf(optarg, "%u", &mpath_mx_alloc_len)) {
4728c8
-                                        fprintf(stderr, "bad argument to '--alloc-length'\n");
4728c8
-                                        return MPATH_PR_SYNTAX_ERROR;
4728c8
+					fprintf(stderr, "bad argument to '--alloc-length'\n");
4728c8
+					ret = MPATH_PR_SYNTAX_ERROR;
4728c8
+					goto out;
4728c8
                                 } else if (MPATH_MAX_PARAM_LEN < mpath_mx_alloc_len) {
4728c8
-                                        fprintf(stderr, "'--alloc-length' argument exceeds maximum"
4728c8
-                                                        " limit(%d)\n", MPATH_MAX_PARAM_LEN);
4728c8
-                                        return MPATH_PR_SYNTAX_ERROR;
4728c8
+					fprintf(stderr, "'--alloc-length' argument exceeds maximum limit(%d)\n", MPATH_MAX_PARAM_LEN);
4728c8
+					ret = MPATH_PR_SYNTAX_ERROR;
4728c8
+					goto out;
4728c8
                                 }
4728c8
                                 break;
4728c8
 
4728c8
@@ -465,14 +473,14 @@ static int handle_args(int argc, char *
4728c8
 		{
4728c8
 			fprintf (stderr, "failed to allocate PRIN response buffer\n");
4728c8
 			ret = MPATH_PR_OTHER;
4728c8
-			goto out;
4728c8
+			goto out_fd;
4728c8
 		}
4728c8
 
4728c8
 		ret = __mpath_persistent_reserve_in (fd, prin_sa, resp, noisy);
4728c8
 		if (ret != MPATH_PR_SUCCESS )
4728c8
 		{
4728c8
 			fprintf (stderr, "Persistent Reserve IN command failed\n");
4728c8
-			goto out;	
4728c8
+			goto out_fd;	
4728c8
 		}
4728c8
 
4728c8
 		switch(prin_sa)
4728c8
@@ -552,8 +560,8 @@ static int handle_args(int argc, char *
4728c8
 		printf("PR out: command failed\n");
4728c8
 	}
4728c8
 
4728c8
+out_fd:
4728c8
 	close (fd);
4728c8
-
4728c8
 out :
4728c8
 	if (ret == MPATH_PR_SYNTAX_ERROR) {
4728c8
 		free(batch_fn);
958de5
Index: multipath-tools-130222/libmpathpersist/mpath_persist.c
958de5
===================================================================
958de5
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.c
958de5
+++ multipath-tools-130222/libmpathpersist/mpath_persist.c
958de5
@@ -585,7 +585,7 @@ int mpath_prout_common(struct multipath
958de5
 			return ret ;
958de5
 		}
958de5
 	}
958de5
-	return MPATH_PR_SUCCESS;
958de5
+	return MPATH_PR_DMMP_ERROR;
958de5
 }
958de5
 
958de5
 int send_prout_activepath(char * dev, int rq_servact, int rq_scope,