public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sesterhenn <snakebyte@gmx.de>
To: linux-kernel@vger.kernel.org
Cc: vbordug@ru.mvista.com
Subject: [Patch] Off-by-one in /arch/ppc/platforms/mpc8*
Date: Tue, 26 Sep 2006 14:28:15 +0200	[thread overview]
Message-ID: <1159273695.6502.5.camel@alice> (raw)

hi,

a find -iname \*.[ch] | xargs grep "> ARRAY_SIZE(" revealed
several incorrect usages of ARRAY_SIZE in the mpc drivers.
The last element in the array is always ARRAY_SIZE()-1,
this patch modifies the bounds checks accordingly.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.18-git5/arch/ppc/platforms/mpc8272ads_setup.c.orig	2006-09-26 14:24:56.000000000 +0200
+++ linux-2.6.18-git5/arch/ppc/platforms/mpc8272ads_setup.c	2006-09-26 14:25:12.000000000 +0200
@@ -196,7 +196,7 @@ static void __init mpc8272ads_fixup_enet
 	bd_t* bi = (void*)__res;
 	int fs_no = fsid_fcc1+pdev->id-1;
 
-	if(fs_no > ARRAY_SIZE(mpc82xx_enet_pdata)) {
+	if(fs_no >= ARRAY_SIZE(mpc82xx_enet_pdata)) {
 		return;
 	}
 
@@ -222,7 +222,7 @@ static void mpc8272ads_fixup_uart_pdata(
 	int id = fs_uart_id_scc2fsid(idx);
 
 	/* no need to alter anything if console */
-	if ((id <= num) && (!pdev->dev.platform_data)) {
+	if ((id < num) && (!pdev->dev.platform_data)) {
 		pinfo = &mpc8272_uart_pdata[id];
 		pinfo->uart_clk = bd->bi_intfreq;
 		pdev->dev.platform_data = pinfo;
--- linux-2.6.18-git5/arch/ppc/platforms/mpc866ads_setup.c.orig	2006-09-26 14:23:08.000000000 +0200
+++ linux-2.6.18-git5/arch/ppc/platforms/mpc866ads_setup.c	2006-09-26 14:23:48.000000000 +0200
@@ -259,7 +259,7 @@ static void mpc866ads_fixup_enet_pdata(s
 	/* Get pointer to Communication Processor */
 	cp = cpmp;
 
-	if(fs_no > ARRAY_SIZE(mpc8xx_enet_pdata)) {
+	if(fs_no >= ARRAY_SIZE(mpc8xx_enet_pdata)) {
 		printk(KERN_ERR"No network-suitable #%d device on bus", fs_no);
 		return;
 	}
@@ -305,7 +305,7 @@ static void __init mpc866ads_fixup_uart_
 	int id = fs_uart_id_smc2fsid(idx);
 
 	/* no need to alter anything if console */
-	if ((id <= num) && (!pdev->dev.platform_data)) {
+	if ((id < num) && (!pdev->dev.platform_data)) {
 		pinfo = &mpc866_uart_pdata[id];
 		pinfo->uart_clk = bd->bi_intfreq;
 		pdev->dev.platform_data = pinfo;
--- linux-2.6.18-git5/arch/ppc/platforms/mpc885ads_setup.c.orig	2006-09-26 14:24:03.000000000 +0200
+++ linux-2.6.18-git5/arch/ppc/platforms/mpc885ads_setup.c	2006-09-26 14:24:31.000000000 +0200
@@ -263,7 +263,7 @@ static void mpc885ads_fixup_enet_pdata(s
 	char *e;
 	int i;
 
-	if(fs_no > ARRAY_SIZE(mpc8xx_enet_pdata)) {
+	if(fs_no >= ARRAY_SIZE(mpc8xx_enet_pdata)) {
 		printk(KERN_ERR"No network-suitable #%d device on bus", fs_no);
 		return;
 	}
@@ -371,7 +371,7 @@ static void __init mpc885ads_fixup_uart_
 	int id = fs_uart_id_smc2fsid(idx);
 
 	/* no need to alter anything if console */
-	if ((id <= num) && (!pdev->dev.platform_data)) {
+	if ((id < num) && (!pdev->dev.platform_data)) {
 		pinfo = &mpc885_uart_pdata[id];
 		pinfo->uart_clk = bd->bi_intfreq;
 		pdev->dev.platform_data = pinfo;



                 reply	other threads:[~2006-09-26 12:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1159273695.6502.5.camel@alice \
    --to=snakebyte@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vbordug@ru.mvista.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox