From patchwork Mon Apr 15 14:13:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 2445291 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id BB32F3FD1A for ; Mon, 15 Apr 2013 14:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753222Ab3DOOOX (ORCPT ); Mon, 15 Apr 2013 10:14:23 -0400 Received: from mail-qe0-f48.google.com ([209.85.128.48]:34633 "EHLO mail-qe0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752650Ab3DOOOU (ORCPT ); Mon, 15 Apr 2013 10:14:20 -0400 Received: by mail-qe0-f48.google.com with SMTP id 2so2660389qea.21 for ; Mon, 15 Apr 2013 07:14:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer; bh=RMfbc/8wHQChppt553BP2nNBU7WMh9fNlhOgeerWU3A=; b=P8oorDoyRIpAqLL3NOQM/xhiBu9QZ55f+EBD4PMgJcoxSGxog7xdvxLcxqXFH5IE5C yJ+IRZax+DpBQzKcz0Lj2bgsJm+J3hMBGFjVCL8ZXDl97WIKhzOQKUeQm1Gf3GqAiWZp h7LDBtsWJTtDU1ETgQTlRBL0IYdNH0r9hXT1ObNrVKNKmunsHQd52Y/+mXb3ExSW4U+l ymo092zcEFP7KyyKep4EeAe9ShdFhrYFGltLyQAoKsg6IheHIEH7BKMwRFi5JxYegTze dOaZe7w1ZIWSmPCVz8/8wiEnM7KGzmNGe10QzBSMsLRfacS/Zo6iqrVzSAk9Z4xtGhin sROw== X-Received: by 10.224.29.145 with SMTP id q17mr22723671qac.75.1366035259862; Mon, 15 Apr 2013 07:14:19 -0700 (PDT) Received: from d2.synalogic.ca (modemcable062.27-82-70.mc.videotron.ca. [70.82.27.62]) by mx.google.com with ESMTPS id hm4sm32615369qab.2.2013.04.15.07.14.18 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 07:14:19 -0700 (PDT) From: Benjamin Poirier To: Michal Marek Cc: "Yann E. MORIN" , Wang YanQing , Dirk Gouders , Paul Gortmaker , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] menuconfig: Fix memory leak introduced by jump keys feature Date: Mon, 15 Apr 2013 10:13:50 -0400 Message-Id: <1366035231-24370-1-git-send-email-bpoirier@suse.de> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Fixes the memory leak of struct jump_key allocated in get_prompt_str() Signed-off-by: Benjamin Poirier --- 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);