public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFT] mfd: rc5t583: Fix array subscript is above array bounds
@ 2012-11-20  2:34 Axel Lin
  2012-11-23 21:33 ` Laxman Dewangan
  2012-11-26 10:53 ` Samuel Ortiz
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-11-20  2:34 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: Laxman Dewangan, linux-kernel

I got below build warning while compiling this driver.
It's obviously RC5T583_MAX_INTERRUPT_MASK_REGS is 9 but irq_en_add array only
has 8 elements.

  CC      drivers/mfd/rc5t583-irq.o
drivers/mfd/rc5t583-irq.c: In function 'rc5t583_irq_sync_unlock':
drivers/mfd/rc5t583-irq.c:227: warning: array subscript is above array bounds
drivers/mfd/rc5t583-irq.c: In function 'rc5t583_irq_init':
drivers/mfd/rc5t583-irq.c:349: warning: array subscript is above array bounds

Since the number of interrupt enable registers is 8, this patch adds define for
RC5T583_MAX_INTERRUPT_EN_REGS to fix this bug.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Hi Laxman,
  I don't have this hardware, I'd appreciate if you can review and test this patch.
Thank you,
Axel
 drivers/mfd/rc5t583-irq.c   |    2 +-
 include/linux/mfd/rc5t583.h |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/rc5t583-irq.c b/drivers/mfd/rc5t583-irq.c
index fe00cdd..b41db59 100644
--- a/drivers/mfd/rc5t583-irq.c
+++ b/drivers/mfd/rc5t583-irq.c
@@ -345,7 +345,7 @@ int rc5t583_irq_init(struct rc5t583 *rc5t583, int irq, int irq_base)
 	mutex_init(&rc5t583->irq_lock);
 
 	/* Initailize all int register to 0 */
-	for (i = 0; i < RC5T583_MAX_INTERRUPT_MASK_REGS; i++)  {
+	for (i = 0; i < RC5T583_MAX_INTERRUPT_EN_REGS; i++)  {
 		ret = rc5t583_write(rc5t583->dev, irq_en_add[i],
 				rc5t583->irq_en_reg[i]);
 		if (ret < 0)
diff --git a/include/linux/mfd/rc5t583.h b/include/linux/mfd/rc5t583.h
index 36c242e..fd413cc 100644
--- a/include/linux/mfd/rc5t583.h
+++ b/include/linux/mfd/rc5t583.h
@@ -33,6 +33,7 @@
 /* Maximum number of main interrupts */
 #define MAX_MAIN_INTERRUPT		5
 #define RC5T583_MAX_GPEDGE_REG		2
+#define RC5T583_MAX_INTERRUPT_EN_REGS	8
 #define RC5T583_MAX_INTERRUPT_MASK_REGS	9
 
 /* Interrupt enable register */
@@ -304,7 +305,7 @@ struct rc5t583 {
 	uint8_t		intc_inten_reg;
 
 	/* For group interrupt bits and address */
-	uint8_t		irq_en_reg[RC5T583_MAX_INTERRUPT_MASK_REGS];
+	uint8_t		irq_en_reg[RC5T583_MAX_INTERRUPT_EN_REGS];
 
 	/* For gpio edge */
 	uint8_t		gpedge_reg[RC5T583_MAX_GPEDGE_REG];
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RFT] mfd: rc5t583: Fix array subscript is above array bounds
  2012-11-20  2:34 [PATCH RFT] mfd: rc5t583: Fix array subscript is above array bounds Axel Lin
@ 2012-11-23 21:33 ` Laxman Dewangan
  2012-11-26 10:53 ` Samuel Ortiz
  1 sibling, 0 replies; 3+ messages in thread
From: Laxman Dewangan @ 2012-11-23 21:33 UTC (permalink / raw)
  To: Axel Lin; +Cc: Samuel Ortiz, linux-kernel@vger.kernel.org

On Tuesday 20 November 2012 08:04 AM, Axel Lin wrote:
> I got below build warning while compiling this driver.
> It's obviously RC5T583_MAX_INTERRUPT_MASK_REGS is 9 but irq_en_add array only
> has 8 elements.
>
>    CC      drivers/mfd/rc5t583-irq.o
> drivers/mfd/rc5t583-irq.c: In function 'rc5t583_irq_sync_unlock':
> drivers/mfd/rc5t583-irq.c:227: warning: array subscript is above array bounds
> drivers/mfd/rc5t583-irq.c: In function 'rc5t583_irq_init':
> drivers/mfd/rc5t583-irq.c:349: warning: array subscript is above array bounds
>
> Since the number of interrupt enable registers is 8, this patch adds define for
> RC5T583_MAX_INTERRUPT_EN_REGS to fix this bug.
>
> Signed-off-by: Axel Lin<axel.lin@ingics.com>
> ---
> Hi Laxman,
>    I don't have this hardware, I'd appreciate if you can review and test this patch.
> Thank you,
> Axel

This looks good. I dont see any issue on this.
I am planning to move this to regmap-irq, probably on next release.

Acked-by: Laxman Dewangan <ldewangan@nvidia.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RFT] mfd: rc5t583: Fix array subscript is above array bounds
  2012-11-20  2:34 [PATCH RFT] mfd: rc5t583: Fix array subscript is above array bounds Axel Lin
  2012-11-23 21:33 ` Laxman Dewangan
@ 2012-11-26 10:53 ` Samuel Ortiz
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Ortiz @ 2012-11-26 10:53 UTC (permalink / raw)
  To: Axel Lin; +Cc: Laxman Dewangan, linux-kernel

Hi Axel,

On Tue, Nov 20, 2012 at 10:34:56AM +0800, Axel Lin wrote:
> I got below build warning while compiling this driver.
> It's obviously RC5T583_MAX_INTERRUPT_MASK_REGS is 9 but irq_en_add array only
> has 8 elements.
> 
>   CC      drivers/mfd/rc5t583-irq.o
> drivers/mfd/rc5t583-irq.c: In function 'rc5t583_irq_sync_unlock':
> drivers/mfd/rc5t583-irq.c:227: warning: array subscript is above array bounds
> drivers/mfd/rc5t583-irq.c: In function 'rc5t583_irq_init':
> drivers/mfd/rc5t583-irq.c:349: warning: array subscript is above array bounds
> 
> Since the number of interrupt enable registers is 8, this patch adds define for
> RC5T583_MAX_INTERRUPT_EN_REGS to fix this bug.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> Hi Laxman,
>   I don't have this hardware, I'd appreciate if you can review and test this patch.
> Thank you,
> Axel
>  drivers/mfd/rc5t583-irq.c   |    2 +-
>  include/linux/mfd/rc5t583.h |    3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
Applied, thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-26 10:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-20  2:34 [PATCH RFT] mfd: rc5t583: Fix array subscript is above array bounds Axel Lin
2012-11-23 21:33 ` Laxman Dewangan
2012-11-26 10:53 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox