Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2395110imu; Tue, 6 Nov 2018 13:54:28 -0800 (PST) X-Google-Smtp-Source: AJdET5fJSNj7wKT9ik2i2SBLORmgNX93LrPusKCLlba6Rcz7e3OMVcqYgiYxbf09tI3h3IEIt6ol X-Received: by 2002:a63:4745:: with SMTP id w5mr25834327pgk.377.1541541268301; Tue, 06 Nov 2018 13:54:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541541268; cv=none; d=google.com; s=arc-20160816; b=BOM9GA/L5hUcfU3myWNEZs5nrklO8UJnDXLP41P8gnjBRIYe6ZY5deHcDRKflJjqyl 6vdPwPqyTNyr9a2tFhaYKET20484Obn6A32FQ5I/f46a3myesXFjvDkulPloW97PCpXz FBgFBswk/KuY12NTJqCYPxbp5bZgN3F6zCx9LVY7feLGYhuWEAnZylC4cR6Vz88sIaws 0DaebOb8mAAimETI9vLLq62uuZ9QWpdx/st8aEhae/JgvWcjThwdcQCwV6IUnTSOj0g5 iFzPQQfODq71laVdGWDWcRVJZtqknWTcHaOL39WnwP3TlpYnn4sS37+5GLxXYenwYJOF t5dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=7EZeQZOqoVG9l8hEukT1IBxrXoWlohjcTttSK64otuc=; b=0XjTRvnZkWg9g7McxENuRuTUE/TLhTcgVRCm+UHECRbc+r1e/bT7SvZG5fvYlZrPDK LJx7Czbd5NMnMwa20OWZBAMLd4DSFUXWC/zNzvdsGjBFVGeWwCW87m687lbcminOVFnG e28IIoG6V8OCtJoKt3gDya88DPE3a0LQrrnNYVjwOqv80Fc/ORZuInGhrjwyEOgfuvR0 cHu21szPTbnTVrr/pShe7VMoglHr9AMjSDNATyxANm5DCvGPYOt8HnatIGv6a9k0nfSJ dwk2sPihYVsz45QNBNk+afWiah7ZQMxo5V3aN74iO8FVGKbxBtwWB+CUshmBNdU93jJD twIg== 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 n15-v6si49250866pgc.143.2018.11.06.13.54.13; Tue, 06 Nov 2018 13:54:28 -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 S1730680AbeKGHLp (ORCPT + 99 others); Wed, 7 Nov 2018 02:11:45 -0500 Received: from andre.telenet-ops.be ([195.130.132.53]:53154 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbeKGHLp (ORCPT ); Wed, 7 Nov 2018 02:11:45 -0500 Received: from ramsan.of.borg ([84.194.111.163]) by andre.telenet-ops.be with bizsmtp id wlkM1y00G3XaVaC01lkM05; Tue, 06 Nov 2018 22:44:27 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1gK993-0002DL-7f; Tue, 06 Nov 2018 22:44:21 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1gK993-0002xn-4j; Tue, 06 Nov 2018 22:44:21 +0100 From: Geert Uytterhoeven To: Ricardo Ribalda Delgado , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Linus Walleij Cc: linux-mtd@lists.infradead.org, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH next] mtd: maps: physmap: Fix infinite loop crash in ROM type probing Date: Tue, 6 Nov 2018 22:44:16 +0100 Message-Id: <20181106214416.11342-1-geert@linux-m68k.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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]) -- 2.17.1