From: ant.v.moryakov@gmail.com
To: linux-mtd@lists.infradead.org
Cc: AntonMoryakov <ant.v.moryakov@gmail.com>
Subject: [PATCH] ubifs-utils: common: fix memory leak in devtable.c
Date: Thu, 24 Apr 2025 21:19:22 +0300 [thread overview]
Message-ID: <20250424181922.17531-1-ant.v.moryakov@gmail.com> (raw)
From: AntonMoryakov <ant.v.moryakov@gmail.com>
Report of the static analyzer:
Dynamic memory, referenced by 'line', is allocated at devtable.c:356
by calling function 'getline' and lost at devtable.c:388.
(line: while (getline(&line, &len, f) != -1) {)
Correct explained:
Now line is freed in any exit scenario via out_close which eliminates this error.
Triggers found by static analyzer Svace.
Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.co
---
ubifs-utils/common/devtable.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ubifs-utils/common/devtable.c b/ubifs-utils/common/devtable.c
index 7347f09..2e581ff 100644
--- a/ubifs-utils/common/devtable.c
+++ b/ubifs-utils/common/devtable.c
@@ -392,6 +392,7 @@ int parse_devtable(const char *tbl_file)
out_close:
fclose(f);
+ free(line);
free_devtable_info();
return -1;
}
--
2.34.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next reply other threads:[~2025-04-24 18:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 18:19 ant.v.moryakov [this message]
2025-04-25 3:22 ` [PATCH] ubifs-utils: common: fix memory leak in devtable.c Zhihao Cheng
-- strict thread matches above, loose matches on Subject: below --
2025-05-15 8:25 Anton Moryakov
2025-06-02 5:35 ` David Oberhollenzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250424181922.17531-1-ant.v.moryakov@gmail.com \
--to=ant.v.moryakov@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox