CRIS v32: Should index be positive?
PATCH 1/1 CRIS v32: Should index be positive?
`port' is used as index for writing to pins during allocation/deallocation. It should be positive.
Signed-off-by Roel Kluin <[email protected]>
--- arch/cris/arch-v32/kernel/pinmux.c | 4 ++-- arch/cris/arch-v32/mach-a3/pinmux.c | 2 +- arch/cris/arch-v32/mach-fs/pinmux.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
Found by code analysis, is it required?
arch/cris/arch-v32/kernel/pinmux.c +2 -2
@@ -54,7 +54,7 @@ crisv32_pinmux_alloc(int port, int first_pin, int last_pin, enum pin_mode mode)crisv32_pinmux_init (); -if (port >PORTS ) +if (port >PORTS || port <0 )return -EINVAL ;spin_lock_irqsave (&pinmux_lock, flags);
@@ -197,7 +197,7 @@ crisv32_pinmux_dealloc(int port, int first_pin, int last_pin)crisv32_pinmux_init (); -if (port >PORTS ) +if (port >PORTS || port <0 )return -EINVAL ;spin_lock_irqsave (&pinmux_lock, flags);
arch/cris/arch-v32/mach-a3/pinmux.c +1 -1
@@ -242,7 +242,7 @@ crisv32_pinmux_dealloc(int port, int first_pin, int last_pin)crisv32_pinmux_init (); -if (port >PORTS ) +if (port >PORTS || port <0 )return -EINVAL ;spin_lock_irqsave (&pinmux_lock, flags);
arch/cris/arch-v32/mach-fs/pinmux.c +2 -2
@@ -54,7 +54,7 @@ crisv32_pinmux_alloc(int port, int first_pin, int last_pin, enum pin_mode mode)crisv32_pinmux_init (); -if (port >PORTS ) +if (port >PORTS || port <0 )return -EINVAL ;spin_lock_irqsave (&pinmux_lock, flags);
@@ -195,7 +195,7 @@ int crisv32_pinmux_dealloc(int port, int first_pin, int last_pin)crisv32_pinmux_init (); -if (port >PORTS ) +if (port >PORTS || port <0 )return -EINVAL ;spin_lock_irqsave (&pinmux_lock, flags);
Quoted 2 lines · Roel Kluin
`port' is used as index for writing to pins during allocation/deallocation. It should be positive.
Yup, that's correct. I've added this to the CRIS tree. Thanks!
/^JN - Jesper Nilsson
Signature · 1 line
Jesper Nilsson -- [email protected]