public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [patch -next] V4L/DVB: IR/streamzap: fix usec to nsec conversion
@ 2010-10-12  6:01 Dan Carpenter
  2010-10-12 13:12 ` Jarod Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-10-12  6:01 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Jarod Wilson, linux-media, kernel-janitors

There is an integer overflow here because 0x03000000 * 1000 is too large
for 31 bits.

rawir.duration should be in terms of nsecs.
IR_MAX_DURATION and 0x03000000 are already in terms of nsecs.
STREAMZAP_TIMEOUT and STREAMZAP_RESOLUTION are 255 and 256 respectively
and are in terms of usecs.

The original code had a deadline of 1.005 seconds and the new code has a
deadline of .065 seconds. 

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/media/IR/streamzap.c b/drivers/media/IR/streamzap.c
index 2cf57e6..d5d3cee 100644
--- a/drivers/media/IR/streamzap.c
+++ b/drivers/media/IR/streamzap.c
@@ -221,7 +221,7 @@ static void streamzap_callback(struct urb *urb)
 	struct streamzap_ir *sz;
 	unsigned int i;
 	int len;
-	static int timeout = (((STREAMZAP_TIMEOUT * STREAMZAP_RESOLUTION) &
+	static int timeout = (((STREAMZAP_TIMEOUT * STREAMZAP_RESOLUTION * 1000) &
 				IR_MAX_DURATION) | 0x03000000);
 
 	if (!urb)
@@ -273,7 +273,7 @@ static void streamzap_callback(struct urb *urb)
 				struct ir_raw_event rawir;
 
 				rawir.pulse = false;
-				rawir.duration = timeout * 1000;
+				rawir.duration = timeout;
 				sz->idle = true;
 				if (sz->timeout_enabled)
 					sz_push(sz, rawir);

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

* Re: [patch -next] V4L/DVB: IR/streamzap: fix usec to nsec conversion
  2010-10-12  6:01 [patch -next] V4L/DVB: IR/streamzap: fix usec to nsec conversion Dan Carpenter
@ 2010-10-12 13:12 ` Jarod Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jarod Wilson @ 2010-10-12 13:12 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors

On Tue, Oct 12, 2010 at 08:01:11AM +0200, Dan Carpenter wrote:
> There is an integer overflow here because 0x03000000 * 1000 is too large
> for 31 bits.
> 
> rawir.duration should be in terms of nsecs.
> IR_MAX_DURATION and 0x03000000 are already in terms of nsecs.
> STREAMZAP_TIMEOUT and STREAMZAP_RESOLUTION are 255 and 256 respectively
> and are in terms of usecs.
> 
> The original code had a deadline of 1.005 seconds and the new code has a
> deadline of .065 seconds. 
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Nice catch, fix looks good.

Acked-by: Jarod Wilson <jarod@redhat.com>

-- 
Jarod Wilson
jarod@redhat.com


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

end of thread, other threads:[~2010-10-12 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-12  6:01 [patch -next] V4L/DVB: IR/streamzap: fix usec to nsec conversion Dan Carpenter
2010-10-12 13:12 ` Jarod Wilson

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