Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2398867imu; Tue, 6 Nov 2018 13:59:21 -0800 (PST) X-Google-Smtp-Source: AJdET5cojl8E760b/iNXwgn4QSOQhsgqR+ky0aIo3y2Wgp3RIP0Ct1b8Yp1XQ0jhCk0vMBtL2DEF X-Received: by 2002:a65:57cb:: with SMTP id q11mr19915467pgr.60.1541541561859; Tue, 06 Nov 2018 13:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541541561; cv=none; d=google.com; s=arc-20160816; b=Roh8DSvf9ypYSCxcZ6ccdycewJO9rtY40D0IdqhuxM3178QRj1EPNIQDuF0qm2m/lv cT/7wX7pzPRN6U5ijmNq5c7XFmfQdsp7x/SB6+YgN6hZ3HaJYcdwkTqtjuzS1myz5bEy 94IYyGsemcH0xm7owtdNs1+6XvsElBGUzK31HTJkmqh0zNtuLFvnTHCFrBLbcYqbfFk1 MgB6F3Ij5BqPohx31jUwcptLf5oTbK+pJyY5c8xtmpnDpu7v/6UWH+qfClMPhGWW+uUf d/HYDsAEOhYUZ5hmWQS8XhcOJk5NKCT+9rbnsDxCdIfLPGOon50GXM4kPV/RM6vClyHL +qWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=cqmGUHaXLAgmWEg1aDbzcdOmADIrNKHPONufrI9thMY=; b=JvDAt+b9ypg7A0NCNg/rZrQ/P4IS06GDWqpwpyNmG6z8O5D2sdRILitHtR9VPYKc3i zQlux/MPr8lH+/TzhyOXWzQVXXI5QIhgaEkuxnQfjbGEoC+ckRHNL79pTywmE+P6JbHH 2N1b1D7u6KTRJf0jaYF1WXlLhiOmeDG/0tNPGZeN9LqNb4hUHVOQwVOVlkBHJnBRBJfF 7wQ1RXKyEfyf7mbj9WmKnYerLPUlxrqcaT8tNlYChzTz0EGQH2QyMMBy66EzDYVVUwXo xyQpbfgZjCRRSXxs8TvBHC+BeA5T05SZ22NikHlCqBFuggr0b1oKdgWdhaytdfIn3vSW jddw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 13-v6si37456466pgv.104.2018.11.06.13.59.05; Tue, 06 Nov 2018 13:59:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727289AbeKGH0C (ORCPT + 99 others); Wed, 7 Nov 2018 02:26:02 -0500 Received: from mail.bootlin.com ([62.4.15.54]:38375 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbeKGH0B (ORCPT ); Wed, 7 Nov 2018 02:26:01 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 7716920510; Tue, 6 Nov 2018 22:58:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 22D1020379; Tue, 6 Nov 2018 22:58:30 +0100 (CET) Date: Tue, 6 Nov 2018 22:58:29 +0100 From: Boris Brezillon To: Geert Uytterhoeven Cc: Ricardo Ribalda Delgado , David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Linus Walleij , linux-mtd@lists.infradead.org, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH next] mtd: maps: physmap: Fix infinite loop crash in ROM type probing Message-ID: <20181106225829.5ecbe19e@bbrezillon> In-Reply-To: <20181106214416.11342-1-geert@linux-m68k.org> References: <20181106214416.11342-1-geert@linux-m68k.org> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 6 Nov 2018 22:44:16 +0100 Geert Uytterhoeven wrote: > On Toshiba RBTX4927, where map_probe is supposed to fail: > > Creating 2 MTD partitions on "physmap-flash.0": > 0x000000c00000-0x000001000000 : "boot" > 0x000000000000-0x000000c00000 : "user" > physmap-flash physmap-flash.1: physmap platform flash device: [mem 0x1e000000-0x1effffff] > CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc == 80320f40, ra == 80321004 > ... > Call Trace: > [<80320f40>] get_mtd_chip_driver+0x30/0x8c > [<80321004>] do_map_probe+0x20/0x90 > [<80328448>] physmap_flash_probe+0x484/0x4ec > > The access to rom_probe_types[] was changed from a sentinel-based loop > to an infinite loop, causing a crash when reaching the sentinel. Oops. Do you mind if I fix that in-place (squash your changes in Ricardo's original commit)? > > Fix this by: > - Removing the no longer needed sentinel, > - Limiting the number of loop iterations to the actual number of ROM > types. > > Fixes: c7afe08496fa463e ("mtd: maps: physmap: Invert logic on if/else branch") > Signed-off-by: Geert Uytterhoeven > --- > drivers/mtd/maps/physmap-core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c > index 33b77bd9022ce251..e8c3b250d8421edc 100644 > --- a/drivers/mtd/maps/physmap-core.c > +++ b/drivers/mtd/maps/physmap-core.c > @@ -396,7 +396,7 @@ static int physmap_flash_of_init(struct platform_device *dev) > #endif /* IS_ENABLED(CONFIG_MTD_PHYSMAP_OF) */ > > static const char * const rom_probe_types[] = { > - "cfi_probe", "jedec_probe", "qinfo_probe", "map_rom", NULL > + "cfi_probe", "jedec_probe", "qinfo_probe", "map_rom", > }; > > static const char * const part_probe_types[] = { > @@ -524,7 +524,7 @@ static int physmap_flash_probe(struct platform_device *dev) > } else { > int j; > > - for (j = 0; ARRAY_SIZE(rom_probe_types); j++) { > + for (j = 0; j < ARRAY_SIZE(rom_probe_types); j++) { > info->mtds[i] = do_map_probe(rom_probe_types[j], > &info->maps[i]); > if (info->mtds[i])