All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: linux-kbuild@vger.kernel.org
Cc: Michal Marek <mmarek@suse.cz>,
	Benjamin Poirier <bpoirier@suse.de>,
	"Yann E. MORIN" <yann.morin.1998@free.fr>,
	stable@vger.kernel.org
Subject: [PATCH 1/6] menuconfig: Fix memory leak introduced by jump keys feature
Date: Mon, 22 Apr 2013 23:31:20 +0200	[thread overview]
Message-ID: <edb749f4390b3c1604233dc7c4fb0361f472e712.1366665922.git.yann.morin.1998@free.fr> (raw)
In-Reply-To: <cover.1366665921.git.yann.morin.1998@free.fr>
In-Reply-To: <cover.1366665921.git.yann.morin.1998@free.fr>

From: Benjamin Poirier <bpoirier@suse.de>

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

Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: stable@vger.kernel.org
---
 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


  reply	other threads:[~2013-04-22 21:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22 21:31 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
2013-04-22 21:31 ` Yann E. MORIN [this message]
2013-04-22 21:31 ` [PATCH 2/6] menuconfig: Add "breadcrumbs" navigation aid Yann E. MORIN
2013-04-22 21:31 ` [PATCH 3/6] kconfig/lxdialog: rationalise the include paths where to find {.n}curses{,w}.h Yann E. MORIN
2013-04-22 21:31 ` [PATCH 4/6] kconfig: allow specifying the seed for randconfig Yann E. MORIN
2013-04-22 21:31 ` [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY " Yann E. MORIN
2013-04-23  8:44   ` Michal Marek
2013-04-23 16:34     ` Yann E. MORIN
2013-04-23 20:05       ` Michal Marek
2013-04-23 21:50   ` Yann E. MORIN
2013-04-24 17:56     ` Yann E. MORIN
2013-04-24 22:28       ` Michal Marek
2013-04-22 21:31 ` [PATCH 6/6] kconfig: do randomise choice entries in presence of KCONFIG_ALLCONFIG Yann E. MORIN
2013-04-23  7:07 ` [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN

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=edb749f4390b3c1604233dc7c4fb0361f472e712.1366665922.git.yann.morin.1998@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=bpoirier@suse.de \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=stable@vger.kernel.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 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.