From 3e37422aa875afd918339d6229107c81e95e33e5 Mon Sep 17 00:00:00 2001 From: linqiheng Date: Tue, 10 Jan 2023 03:33:24 +0000 Subject: [PATCH] hmdfs: fix memleak in hmdfs_match_strdup The old *dst would not be freed when parsing duplicated tokens. Signed-off-by: linqiheng --- fs/hmdfs/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/hmdfs/super.c b/fs/hmdfs/super.c index 52cc857f5e45..a4b1170153b3 100644 --- a/fs/hmdfs/super.c +++ b/fs/hmdfs/super.c @@ -63,6 +63,8 @@ static int hmdfs_match_strdup(const substring_t *s, char **dst) if (!dup) return -ENOMEM; + if (*dst) + kfree(*dst); *dst = dup; return 0; -- Gitee