Skip to content

Commit

Permalink
drivers/rtc/rtc-jz4740.c: fix IRQ error check
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Alessandro Zummo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
larsclausen authored and torvalds committed Oct 5, 2012
1 parent 6b8029f commit 7c6a52a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-jz4740.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct jz4740_rtc {

struct rtc_device *rtc;

unsigned int irq;
int irq;

spinlock_t lock;
};
Expand Down

0 comments on commit 7c6a52a

Please sign in to comment.