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

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