Skip to contentSkip to conversation

[dm- devel][PATCH V2]

PATCH In review Zhiqiang Liu 1 participant 2 messages Jul 29, 2020 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 [dm- devel][PATCH V2]

In disassemble_status func, for dealing with selector args, word is allocated by get_word func. However, word is not freed. Then a memory leak occurs.

Here, we call FREE(word) to free word.

Fixes 35ad40b4 ('leastpending IO loadbalancing is not displayed properly')
---
 libmultipath/dmparser.c | 5 +++++
 1 file changed, 5 insertions(+)
libmultipath/dmparser.c +5 -0
index 3dc77242..33f47405 100644
@@ -580,10 +580,15 @@ int disassemble_status(char *params, struct multipath *mpp)
 				if (!strncmp(mpp->selector,
 					     "least-pending", 13)) {
 					p += get_word(p, &word);
+
+					if (!word)
+						return 1;
+
 					if (sscanf(word,"%d:*d",
 						   &def_minio) == 1 &&
 					    def_minio != mpp->minio)
 							mpp->minio = def_minio;
+					FREE(word);
 				} else
 					p += get_word(p, NULL);
 			}
Signature · 1 line
2.24.0.windows.2
#1 lore raw

Sorry for forgetting to add a subject.
I will resend the v2 patch.

Quoted 36 lines · Zhiqiang Liu

In disassemble_status func, for dealing with selector args, word is allocated by get_word func. However, word is not freed. Then a memory leak occurs.

Here, we call FREE(word) to free word.

Fixes 35ad40b4 ('leastpending IO loadbalancing is not displayed properly')
---
 libmultipath/dmparser.c | 5 +++++
 1 file changed, 5 insertions(+)
libmultipath/dmparser.c +5 -0
index 3dc77242..33f47405 100644
@@ -580,10 +580,15 @@ int disassemble_status(char *params, struct multipath *mpp)
 				if (!strncmp(mpp->selector,
 					     "least-pending", 13)) {
 					p += get_word(p, &word);
+
+					if (!word)
+						return 1;
+
 					if (sscanf(word,"%d:*d",
 						   &def_minio) == 1 &&
 					    def_minio != mpp->minio)
 							mpp->minio = def_minio;
+					FREE(word);
 				} else
 					p += get_word(p, NULL);
 			}