From patchwork Wed Oct 21 01:09:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartley Sweeten X-Patchwork-Id: 36486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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 0F4CBB7B72 for ; Wed, 21 Oct 2009 12:11:44 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1N0Phc-0006v5-JT; Wed, 21 Oct 2009 01:09:24 +0000 Received: from exprod6og108.obsmtp.com ([64.18.1.21]) by bombadil.infradead.org with smtp (Exim 4.69 #1 (Red Hat Linux)) id 1N0PhU-0006sW-90 for linux-mtd@lists.infradead.org; Wed, 21 Oct 2009 01:09:20 +0000 Received: from source ([63.240.6.3]) (using TLSv1) by exprod6ob108.postini.com ([64.18.5.12]) with SMTP ID DSNKSt5fO8QqAZpjW7a3FsFFjK9cbN9Brp88@postini.com; Tue, 20 Oct 2009 18:09:16 PDT Received: from d01smtp06.Mi8.com ([172.16.1.239]) by Outbound02.Mi8.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 20 Oct 2009 21:09:13 -0400 Received: from mi8nycmail19.Mi8.com ([172.16.7.219]) by d01smtp06.Mi8.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 20 Oct 2009 21:09:14 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: [PATCH] mtd: fix error path in physmap.c Date: Tue, 20 Oct 2009 21:09:22 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] mtd: fix error path in physmap.c Thread-Index: AcpR6x+oywJjn0GDRZ+M5LfeOP5e8A== From: "H Hartley Sweeten" To: X-OriginalArrivalTime: 21 Oct 2009 01:09:14.0513 (UTC) FILETIME=[1AF86010:01CA51EB] X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091020_210916_495261_C48B3B66 X-CRM114-Status: GOOD ( 18.77 ) X-Spam-Score: -4.0 (----) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-4.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [64.18.1.21 listed in list.dnswl.org] Cc: David Woodhouse X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org During the physmap probe, add_mtd_partitions() and add_mtd_device() can both return an error. Add an error path to handle this. Signed-off-by: H Hartley Sweeten Cc: David Woodhouse diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index 3f13a96..966b25d 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c @@ -169,24 +169,28 @@ static int physmap_flash_probe(struct platform_device *dev) goto err_out; #ifdef CONFIG_MTD_PARTITIONS - err = parse_mtd_partitions(info->cmtd, part_probe_types, - &info->parts, 0); - if (err > 0) { - add_mtd_partitions(info->cmtd, info->parts, err); - info->nr_parts = err; - return 0; + info->nr_parts = parse_mtd_partitions(info->cmtd, part_probe_types, + &info->parts, 0); + if (info->nr_parts > 0) { + err = add_mtd_partitions(info->cmtd, info->parts, + info->nr_parts); + goto out; } if (physmap_data->nr_parts) { printk(KERN_NOTICE "Using physmap partition information\n"); - add_mtd_partitions(info->cmtd, physmap_data->parts, - physmap_data->nr_parts); - return 0; + err = add_mtd_partitions(info->cmtd, physmap_data->parts, + physmap_data->nr_parts); + goto out; } #endif - add_mtd_device(info->cmtd); - return 0; + if (add_mtd_device(info->cmtd) == 1) + err = -ENODEV; + +out: + if (!err) + return 0; err_out: physmap_flash_remove(dev);