All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 01/12] profile_create_node: set magic before strdup(name) to avoid memory leak
@ 2021-06-30  8:27 wuguanghao
  2021-06-30  8:27 ` [PATCH v2 02/12] tdb_transaction_recover: fix " wuguanghao
                   ` (11 more replies)
  0 siblings, 12 replies; 27+ messages in thread
From: wuguanghao @ 2021-06-30  8:27 UTC (permalink / raw)
  To: linux-ext4, artem.blagodarenko; +Cc: liuzhiqiang26, linfeilong, wuguanghao3

If new->magic != PROF_MAGIC_NODE, profile_free_node() don't free node.
This will cause the node to be unable to be released correctly and
a memory leak will occur.

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reviewed-by: Wu Bo <wubo40@huawei.com>
---
 lib/support/profile.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/support/profile.c b/lib/support/profile.c
index 585ed595..2eb3a9d1 100644
--- a/lib/support/profile.c
+++ b/lib/support/profile.c
@@ -1093,6 +1093,8 @@ errcode_t profile_create_node(const char *name, const char *value,
 	if (!new)
 		return ENOMEM;
 	memset(new, 0, sizeof(struct profile_node));
+	new->magic = PROF_MAGIC_NODE;
+
 	new->name = strdup(name);
 	if (new->name == 0) {
 	    profile_free_node(new);
@@ -1105,7 +1107,6 @@ errcode_t profile_create_node(const char *name, const char *value,
 		    return ENOMEM;
 		}
 	}
-	new->magic = PROF_MAGIC_NODE;
 
 	*ret_node = new;
 	return 0;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2021-07-19 11:08 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30  8:27 [PATCH v2 01/12] profile_create_node: set magic before strdup(name) to avoid memory leak wuguanghao
2021-06-30  8:27 ` [PATCH v2 02/12] tdb_transaction_recover: fix " wuguanghao
2021-07-16  3:19   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 03/12] zap_sector: " wuguanghao
2021-07-16  3:20   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 04/12] ss_add_info_dir: fix memory leak and check whether wuguanghao
2021-07-16  3:27   ` Theodore Y. Ts'o
2021-07-17  3:10     ` Zhiqiang Liu
2021-06-30  8:27 ` [PATCH v2 05/12] ss_create_invocation: fix memory leak and check whether NULL pointer wuguanghao
2021-07-16  3:34   ` Theodore Y. Ts'o
2021-07-19 11:08     ` Zhiqiang Liu
2021-06-30  8:27 ` [PATCH v2 06/12] append_pathname: check the value returned by realloc wuguanghao
2021-07-16  3:39   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 07/12] argv_parse: check return value of malloc in argv_parse() wuguanghao
2021-07-16  3:41   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 08/12] misc: fix potential segmentation fault problem in scandir() wuguanghao
2021-07-16  3:44   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 09/12] lib/ss/error.c: check return value malloc in ss_name() wuguanghao
2021-07-16  3:46   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 10/12] hashmap: change return value type of ext2fs_hashmap_add() wuguanghao
2021-07-16  3:55   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 11/12] misc/lsattr: check whether path is NULL in lsattr_dir_proc() wuguanghao
2021-07-16  3:58   ` Theodore Y. Ts'o
2021-07-17  1:39     ` Zhiqiang Liu
2021-06-30  8:27 ` [PATCH v2 12/12] ext2ed: fix potential NULL pointer dereference in dupstr() wuguanghao
2021-07-16  3:59   ` Theodore Y. Ts'o
2021-07-16  3:18 ` [PATCH v2 01/12] profile_create_node: set magic before strdup(name) to avoid memory leak Theodore Y. Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.