lkml.org 
[lkml]   [2012]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] RTC: JZ4740: Fix IRQ error check
Date
The irq field of the jz4740_irc struct is unsigned. Yet we assign the result of
platform_get_irq() to it. platform_get_irq() may return a negative error code
and the code checks for this condition by checking if 'irq' is less than zero.
But since 'irq' is unsigned this test will always be false. Fix it by making
'irq' signed.

The issue was found using the following coccinelle semantic patch:

//<smpl>
@@
type T;
unsigned T i;
@@
(
*i < 0
|
*i >= 0
)
//</smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/rtc/rtc-jz4740.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index 05ab227..1224182 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -42,7 +42,7 @@ struct jz4740_rtc {

struct rtc_device *rtc;

- unsigned int irq;
+ int irq;

spinlock_t lock;
};
--
1.7.10.4


\
 
 \ /
  Last update: 2012-08-21 16:21    [W:0.037 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site