From patchwork Thu Aug 6 23:05:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 30904 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 754A2B7079 for ; Fri, 7 Aug 2009 09:21:02 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MZCEi-0000We-5e; Thu, 06 Aug 2009 23:19:04 +0000 Received: from smtp1.linux-foundation.org ([140.211.169.13]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1MZCEW-0000UA-Tg; Thu, 06 Aug 2009 23:19:00 +0000 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n76NIikE017945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Aug 2009 16:18:50 -0700 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id n76N5aeS004967; Thu, 6 Aug 2009 16:05:36 -0700 Message-Id: <200908062305.n76N5aeS004967@imap1.linux-foundation.org> Subject: [patch 6/8] slram: fix read buffer overflow To: dwmw2@infradead.org From: akpm@linux-foundation.org Date: Thu, 06 Aug 2009 16:05:36 -0700 X-Spam-Status: No, hits=-3.512 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 X-Spam-Score: 0.0 (/) Cc: roel.kluin@gmail.com, akpm@linux-foundation.org, linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.11 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 From: Roel Kluin map[count] is checked before count < SLRAM_MAX_DEVICES_PARAMS declared on drivers/mtd/devices/slram.c:66: static char *map[SLRAM_MAX_DEVICES_PARAMS]; [akpm@linux-foundation.org: cleanups] Signed-off-by: Roel Kluin Cc: David Woodhouse Signed-off-by: Andrew Morton --- drivers/mtd/devices/slram.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff -puN drivers/mtd/devices/slram.c~slram-read-buffer-overflow drivers/mtd/devices/slram.c --- a/drivers/mtd/devices/slram.c~slram-read-buffer-overflow +++ a/drivers/mtd/devices/slram.c @@ -341,9 +341,8 @@ static int __init init_slram(void) #else int count; - for (count = 0; (map[count]) && (count < SLRAM_MAX_DEVICES_PARAMS); - count++) { - } + for (count = 0; count < SLRAM_MAX_DEVICES_PARAMS && map[count]; count++) + ; if ((count % 3 != 0) || (count == 0)) { E("slram: not enough parameters.\n");