Skip to contentSkip to conversation

ubifs-utils: common: fix memory leak in devtable.c

PATCH Applied Anton Moryakov 2 participants 2 messages May 15, 2025 – Jun 2, 2025 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ubifs-utils: common: fix memory leak in devtable.c

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.

---
 ubifs-utils/common/devtable.c | 1 +
 1 file changed, 1 insertion(+)
ubifs-utils/common/devtable.c +1 -0
index 7347f09..2e581ff 100644
@@ -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/