Skip to content

Commit

Permalink
[media] IR/streamzap: fix usec to nsec conversion
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Dan Carpenter authored and Mauro Carvalho Chehab committed Oct 21, 2010
1 parent b768d47 commit b784cfc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/media/IR/streamzap.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static void streamzap_callback(struct urb *urb)
struct streamzap_ir *sz;
unsigned int i;
int len;
static int timeout = (((SZ_TIMEOUT * SZ_RESOLUTION) &
static int timeout = (((SZ_TIMEOUT * SZ_RESOLUTION * 1000) &
IR_MAX_DURATION) | 0x03000000);

if (!urb)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b784cfc

Please sign in to comment.