summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2018-03-23 07:13:06 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2018-03-23 07:14:47 -0400
commit9863bc49abade85cad2ef6c1f535f61c2c24f163 (patch)
tree680f99a92b910c0596e9eb92f33c1c796676ce69 /drivers/media
parentc3902dab05a2a256607764ac0b5688f29ac544c7 (diff)
downloadlinux-stable-9863bc49abade85cad2ef6c1f535f61c2c24f163.tar.gz
linux-stable-9863bc49abade85cad2ef6c1f535f61c2c24f163.tar.bz2
linux-stable-9863bc49abade85cad2ef6c1f535f61c2c24f163.zip
media: ir-kbd-i2c: change the if logic to avoid a warning
While the code is correct, it produces this warning: drivers/media/i2c/ir-kbd-i2c.c:593 zilog_ir_format() error: buffer overflow 'code_block->codes' 61 <= 173 As static analyzers may be tricked by arithmetic expressions on comparisions. So, change the order, in order to shut up this false-positive warning. That also makes easier for humans to understand that it won't be trying to go past buffer size. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 1d11aab1817a..a7e23bcf845c 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -583,7 +583,7 @@ static int zilog_ir_format(struct rc_dev *rcdev, unsigned int *txbuf,
/* first copy any leading non-repeating */
int leading = c - rep * 3;
- if (leading + rep >= ARRAY_SIZE(code_block->codes) - 3) {
+ if (leading >= ARRAY_SIZE(code_block->codes) - 3 - rep) {
dev_warn(&rcdev->dev, "IR too long, cannot transmit\n");
return -EINVAL;
}