summaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/ir-rc6-decoder.c
diff options
context:
space:
mode:
authorSean Young2018-01-05 14:26:51 +0100
committerMauro Carvalho Chehab2018-01-23 13:26:50 +0100
commitddf9c1bb3d2ae24a216237d8195bb31ff632d8e5 (patch)
treeba9dcf0d8b1e87c6e3f67c4e4f5af6c2798e7993 /drivers/media/rc/ir-rc6-decoder.c
parentmedia: lirc: lirc mode ioctls deal with current mode (diff)
downloadkernel-qcow2-linux-ddf9c1bb3d2ae24a216237d8195bb31ff632d8e5.tar.gz
kernel-qcow2-linux-ddf9c1bb3d2ae24a216237d8195bb31ff632d8e5.tar.xz
kernel-qcow2-linux-ddf9c1bb3d2ae24a216237d8195bb31ff632d8e5.zip
media: rc: clean up leader pulse/space for manchester encoding
The IR rc6 encoder sends the header using manchester encoding using 0 bits, which causes the following: UBSAN: Undefined behaviour in drivers/media/rc/rc-ir-raw.c:247:6 shift exponent 4294967295 is too large for 64-bit type 'long long unsigned int' So, allow the leader code to send a pulse and space and remove the unused pulse_space_start field. Cc: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc/ir-rc6-decoder.c')
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index 665025303c28..422dec08738c 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -288,13 +288,8 @@ out:
static const struct ir_raw_timings_manchester ir_rc6_timings[4] = {
{
- .leader = RC6_PREFIX_PULSE,
- .pulse_space_start = 0,
- .clock = RC6_UNIT,
- .invert = 1,
- .trailer_space = RC6_PREFIX_SPACE,
- },
- {
+ .leader_pulse = RC6_PREFIX_PULSE,
+ .leader_space = RC6_PREFIX_SPACE,
.clock = RC6_UNIT,
.invert = 1,
},
@@ -329,27 +324,22 @@ static int ir_rc6_encode(enum rc_proto protocol, u32 scancode,
struct ir_raw_event *e = events;
if (protocol == RC_PROTO_RC6_0) {
- /* Modulate the preamble */
- ret = ir_raw_gen_manchester(&e, max, &ir_rc6_timings[0], 0, 0);
- if (ret < 0)
- return ret;
-
/* Modulate the header (Start Bit & Mode-0) */
ret = ir_raw_gen_manchester(&e, max - (e - events),
- &ir_rc6_timings[1],
- RC6_HEADER_NBITS, (1 << 3));
+ &ir_rc6_timings[0],
+ RC6_HEADER_NBITS + 1, (1 << 3));
if (ret < 0)
return ret;
/* Modulate Trailer Bit */
ret = ir_raw_gen_manchester(&e, max - (e - events),
- &ir_rc6_timings[2], 1, 0);
+ &ir_rc6_timings[1], 1, 0);
if (ret < 0)
return ret;
/* Modulate rest of the data */
ret = ir_raw_gen_manchester(&e, max - (e - events),
- &ir_rc6_timings[3], RC6_0_NBITS,
+ &ir_rc6_timings[2], RC6_0_NBITS,
scancode);
if (ret < 0)
return ret;
@@ -372,27 +362,22 @@ static int ir_rc6_encode(enum rc_proto protocol, u32 scancode,
return -EINVAL;
}
- /* Modulate the preamble */
- ret = ir_raw_gen_manchester(&e, max, &ir_rc6_timings[0], 0, 0);
- if (ret < 0)
- return ret;
-
/* Modulate the header (Start Bit & Header-version 6 */
ret = ir_raw_gen_manchester(&e, max - (e - events),
- &ir_rc6_timings[1],
- RC6_HEADER_NBITS, (1 << 3 | 6));
+ &ir_rc6_timings[0],
+ RC6_HEADER_NBITS + 1, (1 << 3 | 6));
if (ret < 0)
return ret;
/* Modulate Trailer Bit */
ret = ir_raw_gen_manchester(&e, max - (e - events),
- &ir_rc6_timings[2], 1, 0);
+ &ir_rc6_timings[1], 1, 0);
if (ret < 0)
return ret;
/* Modulate rest of the data */
ret = ir_raw_gen_manchester(&e, max - (e - events),
- &ir_rc6_timings[3],
+ &ir_rc6_timings[2],
bits,
scancode);
if (ret < 0)