From patchwork Mon Apr 22 21:31:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 2473931 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 8381E3FD40 for ; Mon, 22 Apr 2013 21:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753283Ab3DVVbj (ORCPT ); Mon, 22 Apr 2013 17:31:39 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:38899 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753466Ab3DVVbi (ORCPT ); Mon, 22 Apr 2013 17:31:38 -0400 Received: by mail-wi0-f176.google.com with SMTP id hj19so5229597wib.15 for ; Mon, 22 Apr 2013 14:31:36 -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 :in-reply-to:references:in-reply-to:references; bh=qXneNPacPaDBVB20qSlhUIrwLNuAzxgyYYaVoVbPmZc=; b=b9C64cbRPqCodUmJ3fTyAi5yWmJZUX7qsqHWcdTfiEH8GouZZbIvXlXerlSD2+MPM9 +gJ8LGJ/DKl8AZE5EtjazhuKvsir1rfurzvaW8+8Kv7gBwXMEMkzdVhumR1TvzR5HnLg 5X3Z0/klkXzmaIig4ohKal+rQ/vv4QxE1SIu7n+iFMWwUKFkMAmlNF3i5fA1SzYrSQVW PFzRXPe/92K1q25urZkrouZ65MSkTHvGVhTsw2/AkUnrVLelAbdB0JkQXwsVamcMStDW Al+DGVzP9auFL+WA+jrbfjP60w3fI3y/RAk9yTgrOoL3dwAMbAsD3qmDxHwkCpj0JQSe xhoA== X-Received: by 10.194.158.4 with SMTP id wq4mr47050469wjb.46.1366666295610; Mon, 22 Apr 2013 14:31:35 -0700 (PDT) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPS id g9sm24821663wix.1.2013.04.22.14.31.33 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Apr 2013 14:31:34 -0700 (PDT) From: "Yann E. MORIN" To: linux-kbuild@vger.kernel.org Cc: Michal Marek , Benjamin Poirier , "Yann E. MORIN" , 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 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Benjamin Poirier Fixes the memory leak of struct jump_key allocated in get_prompt_str() Signed-off-by: Benjamin Poirier Tested-by: "Yann E. MORIN" Reviewed-by: "Yann E. MORIN" Signed-off-by: "Yann E. MORIN" 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);