From: Dan Carpenter <error27@gmail.com>
To: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Jarod Wilson <jarod@redhat.com>,
linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch -next] V4L/DVB: IR/streamzap: fix usec to nsec conversion
Date: Tue, 12 Oct 2010 08:01:11 +0200 [thread overview]
Message-ID: <20101012060110.GA13176@bicker> (raw)
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);
next reply other threads:[~2010-10-12 6:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-12 6:01 Dan Carpenter [this message]
2010-10-12 13:12 ` [patch -next] V4L/DVB: IR/streamzap: fix usec to nsec conversion Jarod Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101012060110.GA13176@bicker \
--to=error27@gmail.com \
--cc=jarod@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox