* [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool
@ 2020-09-08 8:40 lixiaokeng
2020-09-08 8:44 ` [PATCH V3 01/14] multipathd: initialize major and minor in cli_add_map lixiaokeng
` (8 more replies)
0 siblings, 9 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:40 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
Patches 01, 02, 04, 05, 06, 09, 11, 12, 14 have some changes.
V3 is same as V2.
Changes in V2:
- patch 01: set major and minor to -1 at begining, as suggested
by Martin Wilck
- patch 02: chanege malloc to calloc to calloc, as suggested by
Martin Wilck
- patch 04: delete seting ret when jump to out, as suggested by
Martin Wilck
- patch 05: turn back MALLOC to malloc and reomve error message,
as suggested by Martin Wilck
- patch 06: change malloc to xmalloc, as suggested by Martin Wilck
- patch 09: use ?: instead of checking mp->features, as suggested
by Benjamin Marzinski
- patch 11: change num_transport to num_transportids to combine them,
as suggested by Benjamin Marzinski
- patch 12: delete continue and add remove_map, as suggested by
Martin Wilck
- patch 14: modify patch because of patch 11 "mpathpersist: check
whether malloc paramp->trnptid_list fails in handle_args func"
changing
Zhiqiang Liu (7):
multipathd: use MALLOC and check return value in cli_getprkey func
kpartx: check return value of malloc in main func
libmultipath: check return value of dm_mapname in sysfs_check_holders
libmultipath: donot free *dst if REALLOC fails in merge_words
libmultipath: check whether mp->features is NUll in assemble_map
util/tests: use assert_non_null to ensure malloc returns non-null
pointer
mpathpersist: check whether malloc paramp->trnptid_list fails in
handle_args func
lixiaokeng (7):
multipathd: initialize major and minor in cli_add_map
libmultipath: change malloc to calloc in print_foreign_topology
libmultipath: use map instead of dm_task_get_name
multipathd: check MALLOC return value in mpath_pr_event_handler_fn
libmultipathpersist: use update_multipath_table/status in get_mpvec
multipath: use update_multipath_table/status in check_useable_paths
multipathpersist: delete unused variable in handle_args
kpartx/kpartx.c | 5 ++-
libmpathpersist/mpath_persist.c | 15 +++-----
libmultipath/devmapper.c | 2 +-
libmultipath/dmparser.c | 17 +++------
libmultipath/foreign.c | 4 +-
libmultipath/sysfs.c | 6 ++-
mpathpersist/main.c | 66 +++++++++++++++++++++++++--------
multipath/main.c | 9 ++---
multipathd/cli_handlers.c | 4 +-
multipathd/main.c | 8 ++--
tests/util.c | 2 +
11 files changed, 86 insertions(+), 52 deletions(-)
--
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH V3 01/14] multipathd: initialize major and minor in cli_add_map
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
@ 2020-09-08 8:44 ` lixiaokeng
2020-09-08 8:46 ` [PATCH V3 02/14] libmultipath: change malloc to calloc in print_foreign_topology lixiaokeng
` (7 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:44 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
If dm_get_major_minor failed, log with major and minor should not
be printed to avoid major and minor used before initialization.
V1->V2: set major and minor to -1 at begining
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Linfeilong <linfeilong@huawei.com>
---
multipathd/cli_handlers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 8db37961..e9698704 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -820,7 +820,7 @@ cli_add_map (void * v, char ** reply, int * len, void * data)
{
struct vectors * vecs = (struct vectors *)data;
char * param = get_keyparam(v, MAP);
- int major, minor;
+ int major = -1, minor = -1;
char dev_path[PATH_SIZE];
char *refwwid, *alias = NULL;
int rc, count = 0;
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 02/14] libmultipath: change malloc to calloc in print_foreign_topology
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
2020-09-08 8:44 ` [PATCH V3 01/14] multipathd: initialize major and minor in cli_add_map lixiaokeng
@ 2020-09-08 8:46 ` lixiaokeng
2020-09-08 8:48 ` [PATCH V3 04/14] multipathd: check MALLOC return value in mpath_pr_event_handler_fn lixiaokeng
` (6 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:46 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
We check the return value of malloc in print_foreign_topology.
V1->V2: chanege malloc to calloc
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Linfeilong <linfeilong@huawei.com>
---
libmultipath/foreign.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libmultipath/foreign.c b/libmultipath/foreign.c
index e8f61351..fce19347 100644
--- a/libmultipath/foreign.c
+++ b/libmultipath/foreign.c
@@ -544,8 +544,8 @@ void print_foreign_topology(int verbosity)
int buflen = MAX_LINE_LEN * MAX_LINES;
char *buf = NULL, *tmp = NULL;
- buf = malloc(buflen);
- buf[0] = '\0';
+ buf = calloc(1, buflen);
+
while (buf != NULL) {
char *c = buf;
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 04/14] multipathd: check MALLOC return value in mpath_pr_event_handler_fn
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
2020-09-08 8:44 ` [PATCH V3 01/14] multipathd: initialize major and minor in cli_add_map lixiaokeng
2020-09-08 8:46 ` [PATCH V3 02/14] libmultipath: change malloc to calloc in print_foreign_topology lixiaokeng
@ 2020-09-08 8:48 ` lixiaokeng
2020-09-08 8:49 ` [PATCH V3 05/14] multipathd: use MALLOC and check return value in cli_getprkey func lixiaokeng
` (5 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:48 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
In mpath_pr_event_handler_fn, we use MALLOC instead of malloc, and check
the return value of MALLOC.
V1->V2: delete seting ret when jump to out
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Linfeilong <linfeilong@huawei.com>
---
multipathd/main.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/multipathd/main.c b/multipathd/main.c
index 67e9af11..f1264459 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -3365,7 +3365,6 @@ void * mpath_pr_event_handler_fn (void * pathp )
if (resp->prin_descriptor.prin_readkeys.additional_length == 0 )
{
condlog(1, "%s: No key found. Device may not be registered.", pp->dev);
- ret = MPATH_PR_SUCCESS;
goto out;
}
condlog(2, "Multipath reservation_key: 0x%" PRIx64 " ",
@@ -3387,12 +3386,13 @@ void * mpath_pr_event_handler_fn (void * pathp )
{
condlog(0, "%s: Either device not registered or ", pp->dev);
condlog(0, "host is not authorised for registration. Skip path");
- ret = MPATH_PR_OTHER;
goto out;
}
- param= malloc(sizeof(struct prout_param_descriptor));
- memset(param, 0 , sizeof(struct prout_param_descriptor));
+ param = (struct prout_param_descriptor *)MALLOC(sizeof(struct prout_param_descriptor));
+ if (!param)
+ goto out;
+
param->sa_flags = mpp->sa_flags;
memcpy(param->sa_key, &mpp->reservation_key, 8);
param->num_transportid = 0;
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 05/14] multipathd: use MALLOC and check return value in cli_getprkey func
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
` (2 preceding siblings ...)
2020-09-08 8:48 ` [PATCH V3 04/14] multipathd: check MALLOC return value in mpath_pr_event_handler_fn lixiaokeng
@ 2020-09-08 8:49 ` lixiaokeng
2020-09-08 14:32 ` Martin Wilck
2020-09-08 8:49 ` [PATCH V3 06/14] kpartx: check return value of malloc in main func lixiaokeng
` (4 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:49 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
In cli_getprkey func, we use MALLOC instead of malloc, and check
the return value of MALLOC.
V1->V2: turn back MALLOC to malloc and reomve error message
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Linfeilong <linfeilong@huawei.com>
---
multipathd/cli_handlers.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index e9698704..235e2a2e 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -1531,6 +1531,8 @@ cli_getprkey(void * v, char ** reply, int * len, void * data)
return 1;
*reply = malloc(26);
+ if (!*reply)
+ return 1;
if (!get_be64(mpp->reservation_key)) {
sprintf(*reply, "none\n");
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH V3 06/14] kpartx: check return value of malloc in main func
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
` (3 preceding siblings ...)
2020-09-08 8:49 ` [PATCH V3 05/14] multipathd: use MALLOC and check return value in cli_getprkey func lixiaokeng
@ 2020-09-08 8:49 ` lixiaokeng
2020-09-08 14:25 ` Martin Wilck
2020-09-08 8:51 ` [PATCH V3 09/14] libmultipath: check whether mp->features is NUll in assemble_map lixiaokeng
` (3 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:49 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
In main func of kpartx.c, we should check return value of
malloc before using it.
V1->V2: change malloc to xmalloc
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
---
kpartx/kpartx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
index 98f6176e..6de3c9c4 100644
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -61,6 +61,9 @@ struct pt {
int ptct = 0;
int udev_sync = 1;
+extern void *
+xmalloc (size_t size);
+
static void
addpts(char *t, ptreader f)
{
@@ -383,7 +386,7 @@ main(int argc, char **argv){
mapname = device + off;
if (delim == NULL) {
- delim = malloc(DELIM_SIZE);
+ delim = xmalloc(DELIM_SIZE);
memset(delim, 0, DELIM_SIZE);
set_delimiter(mapname, delim);
}
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 09/14] libmultipath: check whether mp->features is NUll in assemble_map
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
` (4 preceding siblings ...)
2020-09-08 8:49 ` [PATCH V3 06/14] kpartx: check return value of malloc in main func lixiaokeng
@ 2020-09-08 8:51 ` lixiaokeng
2020-09-08 8:52 ` [PATCH V3 11/14] mpathpersist: check whether malloc paramp->trnptid_list fails in handle_args func lixiaokeng
` (2 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:51 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
In assemble_map func, if add_feature fails and mp->features is
default value (NULL), STRDUP(mp->features) will cause a seg-fault.
In addition, f = STRDUP(mp->features) is just used for APPEND().
We can directly pass mp->features to APPEND().
Here, we firstly check whether mp->features is null.
V1->V2: use ?: instead of checking mp->features
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
---
libmultipath/dmparser.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index 482e9d0e..3c5e016a 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -65,7 +65,7 @@ assemble_map (struct multipath * mp, char * params, int len)
int i, j;
int minio;
int nr_priority_groups, initial_pg_nr;
- char * p, * f;
+ char * p;
const char *const end = params + len;
char no_path_retry[] = "queue_if_no_path";
char retain_hwhandler[] = "retain_attached_hw_handler";
@@ -86,10 +86,8 @@ assemble_map (struct multipath * mp, char * params, int len)
get_linux_version_code() < KERNEL_VERSION(4, 3, 0))
add_feature(&mp->features, retain_hwhandler);
- f = STRDUP(mp->features);
-
- APPEND(p, end, "%s %s %i %i", f, mp->hwhandler, nr_priority_groups,
- initial_pg_nr);
+ APPEND(p, end, "%s %s %i %i", mp->features ? mp->features : 0, mp->hwhandler,
+ nr_priority_groups, initial_pg_nr);
vector_foreach_slot (mp->pg, pgp, i) {
pgp = VECTOR_SLOT(mp->pg, i);
@@ -110,12 +108,10 @@ assemble_map (struct multipath * mp, char * params, int len)
}
}
- FREE(f);
condlog(4, "%s: assembled map [%s]", mp->alias, params);
return 0;
err:
- FREE(f);
return 1;
}
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 11/14] mpathpersist: check whether malloc paramp->trnptid_list fails in handle_args func
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
` (5 preceding siblings ...)
2020-09-08 8:51 ` [PATCH V3 09/14] libmultipath: check whether mp->features is NUll in assemble_map lixiaokeng
@ 2020-09-08 8:52 ` lixiaokeng
2020-09-08 8:53 ` [PATCH V3 12/14] libmultipathpersist: use update_multipath_table/status in get_mpvec lixiaokeng
2020-09-08 8:54 ` [PATCH V3 14/14] multipathpersist: delete unused variable in handle_args lixiaokeng
8 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:52 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
In handle_args func, we donot check whether malloc paramp and
each paramp->trnptid_list[j] fails before using them, it may
cause access NULL pointer.
Here, we add alloc_prout_param_descriptor to allocate and init
paramp, and we add free_prout_param_descriptor to free paramp
and each paramp->trnptid_list[j].
V1->V2: change num_transport to num_transportids to combine them.
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
---
mpathpersist/main.c | 65 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 50 insertions(+), 15 deletions(-)
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index 28bfe410..da67c15c 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -153,6 +153,38 @@ static int do_batch_file(const char *batch_fn)
return ret;
}
+static struct prout_param_descriptor *
+alloc_prout_param_descriptor(int num_transportid)
+{
+ struct prout_param_descriptor *paramp;
+
+ if (num_transportid < 0 || num_transportid > MPATH_MX_TIDS)
+ return NULL;
+
+ paramp= malloc(sizeof(struct prout_param_descriptor) +
+ (sizeof(struct transportid *) * num_transportid));
+
+ if (!paramp)
+ return NULL;
+
+ paramp->num_transportid = num_transportid;
+ memset(paramp, 0, sizeof(struct prout_param_descriptor) +
+ (sizeof(struct transportid *) * num_transportid));
+ return paramp;
+}
+
+static void free_prout_param_descriptor(struct prout_param_descriptor *paramp)
+{
+ int i;
+ if (!paramp)
+ return;
+
+ for (i = 0; i < paramp->num_transportid; i++)
+ free(paramp->trnptid_list[i]);
+
+ free(paramp);
+}
+
static int handle_args(int argc, char * argv[], int nline)
{
int c;
@@ -177,7 +209,6 @@ static int handle_args(int argc, char * argv[], int nline)
int prin = 1;
int prin_sa = -1;
int prout_sa = -1;
- int num_transport =0;
char *batch_fn = NULL;
void *resp = NULL;
struct transportid * tmp;
@@ -334,13 +365,13 @@ static int handle_args(int argc, char * argv[], int nline)
break;
case 'X':
- if (0 != construct_transportid(optarg, transportids, num_transport)) {
+ if (0 != construct_transportid(optarg, transportids, num_transportids)) {
fprintf(stderr, "bad argument to '--transport-id'\n");
ret = MPATH_PR_SYNTAX_ERROR;
goto out;
}
- ++num_transport;
+ ++num_transportids;
break;
case 'l':
@@ -525,9 +556,12 @@ static int handle_args(int argc, char * argv[], int nline)
int j;
struct prout_param_descriptor *paramp;
- paramp= malloc(sizeof(struct prout_param_descriptor) + (sizeof(struct transportid *)*(MPATH_MX_TIDS )));
-
- memset(paramp, 0, sizeof(struct prout_param_descriptor) + (sizeof(struct transportid *)*(MPATH_MX_TIDS)));
+ paramp = alloc_prout_param_descriptor(num_transportids);
+ if (!paramp) {
+ fprintf(stderr, "malloc paramp failed\n");
+ ret = MPATH_PR_OTHER;
+ goto out_fd;
+ }
for (j = 7; j >= 0; --j) {
paramp->key[j] = (param_rk & 0xff);
@@ -544,13 +578,19 @@ static int handle_args(int argc, char * argv[], int nline)
if (param_aptpl)
paramp->sa_flags |= MPATH_F_APTPL_MASK;
- if (num_transport)
+ if (num_transportids)
{
paramp->sa_flags |= MPATH_F_SPEC_I_PT_MASK;
- paramp->num_transportid = num_transport;
- for (j = 0 ; j < num_transport; j++)
+ paramp->num_transportid = num_transportids;
+ for (j = 0 ; j < num_transportids; j++)
{
paramp->trnptid_list[j] = (struct transportid *)malloc(sizeof(struct transportid));
+ if (!paramp->trnptid_list[j]) {
+ fprintf(stderr, "malloc paramp->trnptid_list[%d] failed.\n", j);
+ ret = MPATH_PR_OTHER;
+ free_prout_param_descriptor(paramp);
+ goto out_fd;
+ }
memcpy(paramp->trnptid_list[j], &transportids[j],sizeof(struct transportid));
}
}
@@ -558,12 +598,7 @@ static int handle_args(int argc, char * argv[], int nline)
/* PROUT commands other than 'register and move' */
ret = __mpath_persistent_reserve_out (fd, prout_sa, 0, prout_type,
paramp, noisy);
- for (j = 0 ; j < num_transport; j++)
- {
- tmp = paramp->trnptid_list[j];
- free(tmp);
- }
- free(paramp);
+ free_prout_param_descriptor(paramp);
}
if (ret != MPATH_PR_SUCCESS)
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 12/14] libmultipathpersist: use update_multipath_table/status in get_mpvec
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
` (6 preceding siblings ...)
2020-09-08 8:52 ` [PATCH V3 11/14] mpathpersist: check whether malloc paramp->trnptid_list fails in handle_args func lixiaokeng
@ 2020-09-08 8:53 ` lixiaokeng
2020-09-08 8:54 ` [PATCH V3 14/14] multipathpersist: delete unused variable in handle_args lixiaokeng
8 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:53 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
The return values of dm_get_map, disassemble_map in get_mpvec
were not checked. Use update_multipath_table/status to instead
of them.
V1->V2: delete continue and add remove_map
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Linfeilong <linfeilong@huawei.com>
---
libmpathpersist/mpath_persist.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index e7256049..1f9817ed 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -323,7 +323,6 @@ get_mpvec (vector curmp, vector pathvec, char * refwwid)
{
int i;
struct multipath *mpp;
- char params[PARAMS_SIZE], status[PARAMS_SIZE];
vector_foreach_slot (curmp, mpp, i){
/*
@@ -341,14 +340,12 @@ get_mpvec (vector curmp, vector pathvec, char * refwwid)
if (refwwid && strncmp (mpp->alias, refwwid, WWID_SIZE - 1))
continue;
- dm_get_map(mpp->alias, &mpp->size, params);
- condlog(3, "params = %s", params);
- dm_get_status(mpp->alias, status);
- condlog(3, "status = %s", status);
- disassemble_map (pathvec, params, mpp);
- update_pathvec_from_dm(pathvec, mpp, DI_CHECKER);
- disassemble_status (status, mpp);
-
+ if (update_multipath_table(mpp, pathvec, DI_CHECKER) != DMP_OK ||
+ update_multipath_status(mpp) != DMP_OK) {
+ condlog(1, "error parsing map %s", mpp->wwid);
+ remove_map(mpp, pathvec, curmp, PURGE_VEC);
+ i--;
+ }
}
return MPATH_PR_SUCCESS ;
}
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 14/14] multipathpersist: delete unused variable in handle_args
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
` (7 preceding siblings ...)
2020-09-08 8:53 ` [PATCH V3 12/14] libmultipathpersist: use update_multipath_table/status in get_mpvec lixiaokeng
@ 2020-09-08 8:54 ` lixiaokeng
8 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-08 8:54 UTC (permalink / raw)
To: Christophe Varoqui, Martin Wilck, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
In handle_args, the tmp isn't used. We delete it.
V1->V2: modify patch because of "mpathpersist: check whether
malloc paramp->trnptid_list fails in handle_args func" changing
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Linfeilong <linfeilong@huawei.com>
---
mpathpersist/main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index da67c15c..85453ac2 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -211,7 +211,6 @@ static int handle_args(int argc, char * argv[], int nline)
int prout_sa = -1;
char *batch_fn = NULL;
void *resp = NULL;
- struct transportid * tmp;
memset(transportids, 0, MPATH_MX_TIDS * sizeof(struct transportid));
--
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH V3 06/14] kpartx: check return value of malloc in main func
2020-09-08 8:49 ` [PATCH V3 06/14] kpartx: check return value of malloc in main func lixiaokeng
@ 2020-09-08 14:25 ` Martin Wilck
2020-09-09 2:04 ` lixiaokeng
0 siblings, 1 reply; 14+ messages in thread
From: Martin Wilck @ 2020-09-08 14:25 UTC (permalink / raw)
To: lixiaokeng, Christophe Varoqui, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
On Tue, 2020-09-08 at 16:49 +0800, lixiaokeng wrote:
> In main func of kpartx.c, we should check return value of
> malloc before using it.
>
> V1->V2: change malloc to xmalloc
>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
> ---
> kpartx/kpartx.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
> index 98f6176e..6de3c9c4 100644
> --- a/kpartx/kpartx.c
> +++ b/kpartx/kpartx.c
> @@ -61,6 +61,9 @@ struct pt {
> int ptct = 0;
> int udev_sync = 1;
>
> +extern void *
> +xmalloc (size_t size);
> +
Please don't use "extern". It's misleading, because this function is
defined in the same file. You should actually change xmalloc() to a
static function.
Regards,
Martin
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V3 05/14] multipathd: use MALLOC and check return value in cli_getprkey func
2020-09-08 8:49 ` [PATCH V3 05/14] multipathd: use MALLOC and check return value in cli_getprkey func lixiaokeng
@ 2020-09-08 14:32 ` Martin Wilck
2020-09-09 2:27 ` lixiaokeng
0 siblings, 1 reply; 14+ messages in thread
From: Martin Wilck @ 2020-09-08 14:32 UTC (permalink / raw)
To: lixiaokeng, Christophe Varoqui, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
On Tue, 2020-09-08 at 16:49 +0800, lixiaokeng wrote:
> In cli_getprkey func, we use MALLOC instead of malloc, and check
> the return value of MALLOC.
>
> V1->V2: turn back MALLOC to malloc and reomve error message
Ok, but now you need to change the patch subject as well...
Also, please don't include v1->v2 changes in the commit message itself.
Once this is committed, it's not interesting how it differs from
earlier versions of the patch. Put it below the "---" marker,
or just mention the version history in the cover letter.
Please see
https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html
Regards,
Martin
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V3 06/14] kpartx: check return value of malloc in main func
2020-09-08 14:25 ` Martin Wilck
@ 2020-09-09 2:04 ` lixiaokeng
0 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-09 2:04 UTC (permalink / raw)
To: Martin Wilck, Christophe Varoqui, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
On 2020/9/8 22:25, Martin Wilck wrote:
> On Tue, 2020-09-08 at 16:49 +0800, lixiaokeng wrote:
>> In main func of kpartx.c, we should check return value of
>> malloc before using it.
>>
>> V1->V2: change malloc to xmalloc
>>
>> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
>> ---
>> kpartx/kpartx.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
>> index 98f6176e..6de3c9c4 100644
>> --- a/kpartx/kpartx.c
>> +++ b/kpartx/kpartx.c
>> @@ -61,6 +61,9 @@ struct pt {
>> int ptct = 0;
>> int udev_sync = 1;
>>
>> +extern void *
>> +xmalloc (size_t size);
>> +
>
> Please don't use "extern". It's misleading, because this function is
> defined in the same file. You should actually change xmalloc() to a
> static function.
>
> Regards,
> Martin
>
Hi Martin,
The function xmalloc should be externed before main even it is changed
to static function. So do you think it is a good idea to move xmalloc
before main? Or move it and change it to static func?
Regards,
Lixiaokeng
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V3 05/14] multipathd: use MALLOC and check return value in cli_getprkey func
2020-09-08 14:32 ` Martin Wilck
@ 2020-09-09 2:27 ` lixiaokeng
0 siblings, 0 replies; 14+ messages in thread
From: lixiaokeng @ 2020-09-09 2:27 UTC (permalink / raw)
To: Martin Wilck, Christophe Varoqui, Benjamin Marzinski,
dm-devel mailing list
Cc: linfeilong, liuzhiqiang (I)
On 2020/9/8 22:32, Martin Wilck wrote:
> On Tue, 2020-09-08 at 16:49 +0800, lixiaokeng wrote:
>> In cli_getprkey func, we use MALLOC instead of malloc, and check
>> the return value of MALLOC.
>>
>> V1->V2: turn back MALLOC to malloc and reomve error message
>
> Ok, but now you need to change the patch subject as well...
>
> Also, please don't include v1->v2 changes in the commit message itself.
> Once this is committed, it's not interesting how it differs from
> earlier versions of the patch. Put it below the "---" marker,
> or just mention the version history in the cover letter.
>
> Please see
> https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html
>
> Regards,
> Martin
>
I will change the message of patches 1, 2, 4, 5, 6, 7, 9, 11, 12, 14
and send them as V4.
Regards,
Lixiaokeng
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-09-09 2:27 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 8:40 [PATCH V3 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool lixiaokeng
2020-09-08 8:44 ` [PATCH V3 01/14] multipathd: initialize major and minor in cli_add_map lixiaokeng
2020-09-08 8:46 ` [PATCH V3 02/14] libmultipath: change malloc to calloc in print_foreign_topology lixiaokeng
2020-09-08 8:48 ` [PATCH V3 04/14] multipathd: check MALLOC return value in mpath_pr_event_handler_fn lixiaokeng
2020-09-08 8:49 ` [PATCH V3 05/14] multipathd: use MALLOC and check return value in cli_getprkey func lixiaokeng
2020-09-08 14:32 ` Martin Wilck
2020-09-09 2:27 ` lixiaokeng
2020-09-08 8:49 ` [PATCH V3 06/14] kpartx: check return value of malloc in main func lixiaokeng
2020-09-08 14:25 ` Martin Wilck
2020-09-09 2:04 ` lixiaokeng
2020-09-08 8:51 ` [PATCH V3 09/14] libmultipath: check whether mp->features is NUll in assemble_map lixiaokeng
2020-09-08 8:52 ` [PATCH V3 11/14] mpathpersist: check whether malloc paramp->trnptid_list fails in handle_args func lixiaokeng
2020-09-08 8:53 ` [PATCH V3 12/14] libmultipathpersist: use update_multipath_table/status in get_mpvec lixiaokeng
2020-09-08 8:54 ` [PATCH V3 14/14] multipathpersist: delete unused variable in handle_args lixiaokeng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).