From patchwork Fri Mar 6 11:01:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atsushi Nemoto X-Patchwork-Id: 24145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 90283DDD04 for ; Fri, 6 Mar 2009 22:06:41 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LfXpC-0008UY-Um; Fri, 06 Mar 2009 11:02:43 +0000 Received: from mba.ocn.ne.jp ([122.1.235.107] helo=smtp.mba.ocn.ne.jp) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LfXnl-0008CC-E3 for linux-mtd@lists.infradead.org; Fri, 06 Mar 2009 11:01:16 +0000 Received: from localhost.localdomain (p7122-ipad205funabasi.chiba.ocn.ne.jp [222.146.102.122]) by smtp.mba.ocn.ne.jp (Postfix) with ESMTP id 022AAB124; Fri, 6 Mar 2009 20:01:08 +0900 (JST) From: Atsushi Nemoto To: linux-mtd@lists.infradead.org Subject: [PATCH] mtdpart: Make all partition parsers return allocated array Date: Fri, 6 Mar 2009 20:01:08 +0900 Message-Id: <1236337268-4891-1-git-send-email-anemo@mba.ocn.ne.jp> X-Mailer: git-send-email 1.5.6.3 X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.4 SUBJECT_FUZZY_TION Attempt to obfuscate words in Subject: Cc: Eugene Konev , Sascha Hauer , David Woodhouse , linux-kernel@vger.kernel.org, Felix Fietkau X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently redboot and afx parser return allocated mtd_partition array and cmdlinepart and ar7 return persistent array. This patch make cmdlinepart and ar7 also return allocated array, so that all users can free it regardless of parser type. Signed-off-by: Atsushi Nemoto --- drivers/mtd/ar7part.c | 6 ++++-- drivers/mtd/cmdlinepart.c | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/ar7part.c b/drivers/mtd/ar7part.c index ecf170b..6697a1e 100644 --- a/drivers/mtd/ar7part.c +++ b/drivers/mtd/ar7part.c @@ -44,8 +44,6 @@ struct ar7_bin_rec { unsigned int address; }; -static struct mtd_partition ar7_parts[AR7_PARTS]; - static int create_mtd_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long origin) @@ -57,7 +55,11 @@ static int create_mtd_partitions(struct mtd_info *master, unsigned int root_offset = ROOT_OFFSET; int retries = 10; + struct mtd_partition *ar7_parts; + ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL); + if (!ar7_parts) + return -ENOMEM; ar7_parts[0].name = "loader"; ar7_parts[0].offset = 0; ar7_parts[0].size = master->erasesize; diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index 50a3403..5011fa7 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c @@ -335,7 +335,11 @@ static int parse_cmdline_partitions(struct mtd_info *master, } offset += part->parts[i].size; } - *pparts = part->parts; + *pparts = kmemdup(part->parts, + sizeof(*part->parts) * part->num_parts, + GFP_KERNEL); + if (!*pparts) + return -ENOMEM; return part->num_parts; } }