diff mbox

[1/2] menuconfig: Fix memory leak introduced by jump keys feature

Message ID 1366035231-24370-1-git-send-email-bpoirier@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Poirier April 15, 2013, 2:13 p.m. UTC
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(+)

Comments

Yann E. MORIN April 15, 2013, 9:54 p.m. UTC | #1
Benjamin, All,

On Mon, Apr 15, 2013 at 10:13:50AM -0400, Benjamin Poirier wrote:
> Fixes the memory leak of struct jump_key allocated in get_prompt_str()

Queued into:
https://git.gitorious.org/linux-kconfig/linux-kconfig.git yem-kconfig-rc-fixes

Although this is strictly a bug fix, I would lean toward waiting for the
next merge window to open before pulling this in.

We can't really say that the kconfig frontends are critical, long-running
processes. If they leak a bit of memory, that's not too cumbersome, I
think. OTOH, I think breaking the frontends so close to the end of the
-rc cycle is a bit dangerous (heck, I would not like to be part of the
cause of a new flaming, just for this! ;-) )

So, unless Michal really wants to pull this one and push it to Linus
before he cuts v3.9 final, I'll merge this later in my -for-next branch.

Thank you!

Regards,
Yann E. MORIN.
Michal Marek April 16, 2013, 8:21 a.m. UTC | #2
On 15.4.2013 23:54, Yann E. MORIN wrote:
> So, unless Michal really wants to pull this one and push it to Linus
> before he cuts v3.9 final, I'll merge this later in my -for-next branch.

That's fine with me.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek April 16, 2013, 9:12 a.m. UTC | #3
On 16.4.2013 10:21, Michal Marek wrote:
> On 15.4.2013 23:54, Yann E. MORIN wrote:
>> So, unless Michal really wants to pull this one and push it to Linus
>> before he cuts v3.9 final, I'll merge this later in my -for-next branch.
> 
> That's fine with me.

BTW, in you are going to rebase the commit, it would be good idea to add
Cc: <stable@vger.kernel.org> to the changelog.

Thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yann E. MORIN April 16, 2013, 4:38 p.m. UTC | #4
Michal, All,

On Tue, Apr 16, 2013 at 11:12:41AM +0200, Michal Marek wrote:
> > On 15.4.2013 23:54, Yann E. MORIN wrote:
> >> So, unless Michal really wants to pull this one and push it to Linus
> >> before he cuts v3.9 final, I'll merge this later in my -for-next branch.
> BTW, in you are going to rebase the commit, it would be good idea to add
> Cc: <stable@vger.kernel.org> to the changelog.

Yes sure.

Regards,
Yann E. MORIN.
diff mbox

Patch

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);