Skip to contentSkip to conversation

exofs: fix potential memory leak in mount option parsing

PATCH New Chengguang Xu 1 participant 1 message Apr 14, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exofs: fix potential memory leak in mount option parsing

When specifying string type mount option several times in a mount, current option parsing may cause memory leak. Hence, call kfree for previous one in this case.

---
 fs/exofs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/exofs/super.c +1 -0
index 179cd5c..106b818 100644
@@ -101,6 +101,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
 		token = match_token(p, tokens, args);
 		switch (token) {
 		case Opt_name:
+			kfree(opts->dev_name);
 			opts->dev_name = match_strdup(&args[0]);
 			if (unlikely(!opts->dev_name)) {
 				EXOFS_ERR("Error allocating dev_name");
Signature · 1 line
1.8.3.1