942c9b6ed8
Update Source to upstream version 0.8.2 * Previoud patches 0001-0017 & 0027 are included in this commit Rename files * Previous patches 0018-0026 & 0028 are not patches 0021-0030 Add 0001-libmultipath-make-vector_foreach_slot_backwards-work.patch Add 0002-libmultipath-add-marginal-paths-and-groups-infrastru.patch Add 0003-tests-add-path-grouping-policy-unit-tests.patch Add 0004-libmultipath-add-wrapper-function-around-pgpolicyfn.patch Add 0005-tests-update-pgpolicy-tests-to-work-with-group_paths.patch Add 0006-libmultipath-fix-double-free-in-pgpolicyfn-error-pat.patch Add 0007-libmultipath-consolidate-group_by_-functions.patch Add 0008-libmultipath-make-pgpolicyfn-take-a-paths-vector.patch Add 0009-libmultipath-make-group_paths-handle-marginal-paths.patch Add 0010-tests-add-tests-for-grouping-marginal-paths.patch Add 0011-libmultipath-add-marginal_pathgroups-config-option.patch Add 0012-libmutipath-deprecate-delay_-_checks.patch Add 0013-multipathd-use-marginal_pathgroups.patch Add 0014-multipath-update-man-pages.patch * The above 13 patches add the marinal_pathgroups option Add 0015-multipath.conf-add-enable_foreign-parameter.patch Add 0016-multipath.conf.5-document-foreign-library-support.patch * The above 2 patches add the enable_foreign option Add 0017-mpathpersist-remove-broken-unused-code.patch Add 0018-libmultipath-EMC-PowerMax-NVMe-device-config.patch Add 0019-mpathpersist-fix-leaks.patch Add 0020-libmultipath-fix-mpcontext-initialization.patch * The above 20 patches have been submitted upstream
133 lines
3.9 KiB
Diff
133 lines
3.9 KiB
Diff
From 385f0a62f83af67eb0b4b67f3af43e149619c0af Mon Sep 17 00:00:00 2001
|
|
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
Date: Tue, 10 Sep 2019 10:44:50 -0500
|
|
Subject: [PATCH] mpathpersist: fix leaks
|
|
|
|
If handle_args() fails while looping through the argument list, it needs
|
|
to free batch_fn, if it has been set. Also handle_args() needs to make
|
|
sure to free the file descriptor after it has been opened.
|
|
|
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
---
|
|
mpathpersist/main.c | 31 ++++++++++++++++++++-----------
|
|
1 file changed, 20 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
|
|
index 5ad06a97..2368b429 100644
|
|
--- a/mpathpersist/main.c
|
|
+++ b/mpathpersist/main.c
|
|
@@ -155,7 +155,8 @@ static int do_batch_file(const char *batch_fn)
|
|
|
|
static int handle_args(int argc, char * argv[], int nline)
|
|
{
|
|
- int fd, c;
|
|
+ int c;
|
|
+ int fd = -1;
|
|
const char *device_name = NULL;
|
|
int num_prin_sa = 0;
|
|
int num_prout_sa = 0;
|
|
@@ -213,7 +214,8 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
if (nline == 0 && 1 != sscanf (optarg, "%d", &loglevel))
|
|
{
|
|
fprintf (stderr, "bad argument to '--verbose'\n");
|
|
- return MPATH_PR_SYNTAX_ERROR;
|
|
+ ret = MPATH_PR_SYNTAX_ERROR;
|
|
+ goto out;
|
|
}
|
|
break;
|
|
|
|
@@ -228,6 +230,7 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
|
|
case 'h':
|
|
usage ();
|
|
+ free(batch_fn);
|
|
return 0;
|
|
|
|
case 'H':
|
|
@@ -254,7 +257,8 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
if (1 != sscanf (optarg, "%" SCNx64 "", ¶m_rk))
|
|
{
|
|
fprintf (stderr, "bad argument to '--param-rk'\n");
|
|
- return MPATH_PR_SYNTAX_ERROR;
|
|
+ ret = MPATH_PR_SYNTAX_ERROR;
|
|
+ goto out;
|
|
}
|
|
++num_prout_param;
|
|
break;
|
|
@@ -263,7 +267,8 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
if (1 != sscanf (optarg, "%" SCNx64 "", ¶m_sark))
|
|
{
|
|
fprintf (stderr, "bad argument to '--param-sark'\n");
|
|
- return MPATH_PR_SYNTAX_ERROR;
|
|
+ ret = MPATH_PR_SYNTAX_ERROR;
|
|
+ goto out;
|
|
}
|
|
++num_prout_param;
|
|
break;
|
|
@@ -282,7 +287,8 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
if (1 != sscanf (optarg, "%x", &prout_type))
|
|
{
|
|
fprintf (stderr, "bad argument to '--prout-type'\n");
|
|
- return MPATH_PR_SYNTAX_ERROR;
|
|
+ ret = MPATH_PR_SYNTAX_ERROR;
|
|
+ goto out;
|
|
}
|
|
++num_prout_param;
|
|
break;
|
|
@@ -330,7 +336,8 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
case 'X':
|
|
if (0 != construct_transportid(optarg, transportids, num_transport)) {
|
|
fprintf(stderr, "bad argument to '--transport-id'\n");
|
|
- return MPATH_PR_SYNTAX_ERROR;
|
|
+ ret = MPATH_PR_SYNTAX_ERROR;
|
|
+ goto out;
|
|
}
|
|
|
|
++num_transport;
|
|
@@ -339,11 +346,13 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
case 'l':
|
|
if (1 != sscanf(optarg, "%u", &mpath_mx_alloc_len)) {
|
|
fprintf(stderr, "bad argument to '--alloc-length'\n");
|
|
- return MPATH_PR_SYNTAX_ERROR;
|
|
+ ret = MPATH_PR_SYNTAX_ERROR;
|
|
+ goto out;
|
|
} else if (MPATH_MAX_PARAM_LEN < mpath_mx_alloc_len) {
|
|
fprintf(stderr, "'--alloc-length' argument exceeds maximum"
|
|
" limit(%d)\n", MPATH_MAX_PARAM_LEN);
|
|
- return MPATH_PR_SYNTAX_ERROR;
|
|
+ ret = MPATH_PR_SYNTAX_ERROR;
|
|
+ goto out;
|
|
}
|
|
break;
|
|
|
|
@@ -481,14 +490,14 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
{
|
|
fprintf (stderr, "failed to allocate PRIN response buffer\n");
|
|
ret = MPATH_PR_OTHER;
|
|
- goto out;
|
|
+ goto out_fd;
|
|
}
|
|
|
|
ret = __mpath_persistent_reserve_in (fd, prin_sa, resp, noisy);
|
|
if (ret != MPATH_PR_SUCCESS )
|
|
{
|
|
fprintf (stderr, "Persistent Reserve IN command failed\n");
|
|
- goto out;
|
|
+ goto out_fd;
|
|
}
|
|
|
|
switch(prin_sa)
|
|
@@ -568,8 +577,8 @@ static int handle_args(int argc, char * argv[], int nline)
|
|
printf("PR out: command failed\n");
|
|
}
|
|
|
|
+out_fd:
|
|
close (fd);
|
|
-
|
|
out :
|
|
if (ret == MPATH_PR_SYNTAX_ERROR) {
|
|
free(batch_fn);
|
|
--
|
|
2.17.2
|
|
|