Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

[PATCH] sh: Make sure indexes are positive

 
   Soft32 Home -> Linux -> Kernel RSS
Next:  [gentoo-user] KDE4 Solid a bit wobbly  
Author Message
Roel Kluin

External


Since: Dec 02, 2008
Posts: 52



(Msg. 1) Posted: Mon Nov 02, 2009 11:20 am
Post subject: [PATCH] sh: Make sure indexes are positive
Archived from groups: linux>kernel (more info?)

The indexes are signed, make sure they are not negative
when we read array elements.

Signed-off-by: Roel Kluin <roel.kluin.TakeThisOut@gmail.com>
---
arch/sh/boards/mach-highlander/setup.c | 2 +-
arch/sh/boards/mach-r2d/irq.c | 2 +-
arch/sh/mm/numa.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

Found by code analysis, is this required?

diff --git a/arch/sh/boards/mach-highlander/setup.c b/arch/sh/boards/mach-highlander/setup.c
index 566e69d..f663c14 100644
--- a/arch/sh/boards/mach-highlander/setup.c
+++ b/arch/sh/boards/mach-highlander/setup.c
@@ -384,7 +384,7 @@ static unsigned char irl2irq[HL_NR_IRL];

static int highlander_irq_demux(int irq)
{
- if (irq >= HL_NR_IRL || !irl2irq[irq])
+ if (irq >= HL_NR_IRL || irq < 0 || !irl2irq[irq])
return irq;

return irl2irq[irq];
diff --git a/arch/sh/boards/mach-r2d/irq.c b/arch/sh/boards/mach-r2d/irq.c
index c70fece..78d7b27 100644
--- a/arch/sh/boards/mach-r2d/irq.c
+++ b/arch/sh/boards/mach-r2d/irq.c
@@ -116,7 +116,7 @@ static unsigned char irl2irq[R2D_NR_IRL];

int rts7751r2d_irq_demux(int irq)
{
- if (irq >= R2D_NR_IRL || !irl2irq[irq])
+ if (irq >= R2D_NR_IRL || irq < 0 || !irl2irq[irq])
return irq;

return irl2irq[irq];
diff --git a/arch/sh/mm/numa.c b/arch/sh/mm/numa.c
index 9b784fd..6c52444 100644
--- a/arch/sh/mm/numa.c
+++ b/arch/sh/mm/numa.c
@@ -60,7 +60,7 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
unsigned long bootmem_paddr;

/* Don't allow bogus node assignment */
- BUG_ON(nid > MAX_NUMNODES || nid == 0);
+ BUG_ON(nid > MAX_NUMNODES || nid <= 0);

start_pfn = start >> PAGE_SHIFT;
end_pfn = end >> PAGE_SHIFT;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.TakeThisOut@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Paul Mundt

External


Since: Nov 13, 2006
Posts: 261



(Msg. 2) Posted: Tue Nov 03, 2009 9:20 pm
Post subject: Re: [PATCH] sh: Make sure indexes are positive [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, Nov 02, 2009 at 05:14:42PM +0100, Roel Kluin wrote:
> The indexes are signed, make sure they are not negative
> when we read array elements.
>
> Signed-off-by: Roel Kluin <roel.kluin.RemoveThis@gmail.com>

In practice none of these are likely to be an issue, but it doesn't
really hurt to add the sanity checks given that there's already a number
of them anyways. So, applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Display posts from previous:   
Related Topics:
PATCH: Fix SVM MSR indexes for 32bit kernel - Hi, MSR index is 32bit not 64bit. All other MSR indexes are defined without the ULL suffix. Otherwise, you will get ..

i8042 lockdep false positive. - I just had a user file the report below, which iirc, was deemed a false positive. Didn't we add something to the code....

checkpatch.pl false positive on exported pointers - WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable #563: FILE:..

[2.6 patch] make configfs_dirent_exists() static - This patch makes the needlessly global configfs_dirent_exists() static. Signed-off-by: Adrian Bunk <bunk@stusta.de&...

[2.6 patch] make ecryptfs_version_str_map[] static - This patch makes the needlessly global ecryptfs_version_str_map[] static. Signed-off-by: Adrian Bunk <bunk@stusta....

[2.6 patch] make ocfs2_create_new_lock() static - This patch makes the needlessly global ocfs2_create_new_lock() static. Signed-off-by: Adrian Bunk <bunk@stusta.de&g...
       Soft32 Home -> Linux -> Kernel All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]