public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] menuconfig: Fix memory leak introduced by jump keys feature
@ 2013-04-15 14:13 Benjamin Poirier
  2013-04-15 14:13 ` [PATCH 2/2] menuconfig: Add "breadcrumbs" navigation aid Benjamin Poirier
  2013-04-15 21:54 ` [PATCH 1/2] menuconfig: Fix memory leak introduced by jump keys feature Yann E. MORIN
  0 siblings, 2 replies; 9+ messages in thread
From: Benjamin Poirier @ 2013-04-15 14:13 UTC (permalink / raw)
  To: Michal Marek
  Cc: Yann E. MORIN, Wang YanQing, Dirk Gouders, Paul Gortmaker,
	linux-kbuild, linux-kernel

Fixes the memory leak of struct jump_key allocated in get_prompt_str()

Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
---
 scripts/kconfig/list.h  |   13 +++++++++++++
 scripts/kconfig/mconf.c |    3 +++
 2 files changed, 16 insertions(+)

diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
index 0ae730b..b87206c 100644
--- a/scripts/kconfig/list.h
+++ b/scripts/kconfig/list.h
@@ -51,6 +51,19 @@ struct list_head {
 	     pos = list_entry(pos->member.next, typeof(*pos), member))
 
 /**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos:	the type * to use as a loop cursor.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member)			\
+	for (pos = list_entry((head)->next, typeof(*pos), member),	\
+		n = list_entry(pos->member.next, typeof(*pos), member);	\
+	     &pos->member != (head);					\
+	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
  * list_empty - tests whether a list is empty
  * @head: the list to test.
  */
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 566288a..c5418d6 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -389,6 +389,7 @@ again:
 			.targets = targets,
 			.keys = keys,
 		};
+		struct jump_key *pos, *tmp;
 
 		res = get_relations_str(sym_arr, &head);
 		dres = show_textbox_ext(_("Search Results"), (char *)
@@ -402,6 +403,8 @@ again:
 				again = true;
 			}
 		str_free(&res);
+		list_for_each_entry_safe(pos, tmp, &head, entries)
+			free(pos);
 	} while (again);
 	free(sym_arr);
 	str_free(&title);
-- 
1.7.10.4


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

end of thread, other threads:[~2013-04-16 17:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-15 14:13 [PATCH 1/2] menuconfig: Fix memory leak introduced by jump keys feature Benjamin Poirier
2013-04-15 14:13 ` [PATCH 2/2] menuconfig: Add "breadcrumbs" navigation aid Benjamin Poirier
2013-04-15 21:39   ` Yann E. MORIN
2013-04-16 14:07     ` [PATCH v3] " Benjamin Poirier
2013-04-16 17:20       ` Yann E. MORIN
2013-04-15 21:54 ` [PATCH 1/2] menuconfig: Fix memory leak introduced by jump keys feature Yann E. MORIN
2013-04-16  8:21   ` Michal Marek
2013-04-16  9:12     ` Michal Marek
2013-04-16 16:38       ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox