summaryrefslogtreecommitdiff
path: root/drivers/media/pci/ddbridge/ddbridge-mci.h
diff options
context:
space:
mode:
authorDaniel Scheller <d.scheller@gmx.net>2018-05-09 23:08:00 +0300
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-05-29 00:43:20 +0300
commit525cac75740542e23c31cd0f248f9b29ae4978e9 (patch)
tree98a7ba3a1574f98363d98d67ebbc5e8970941656 /drivers/media/pci/ddbridge/ddbridge-mci.h
parentd7832cd2a3c87eb6ae1e802c88b6fc56c5823f6d (diff)
downloadlinux-525cac75740542e23c31cd0f248f9b29ae4978e9.tar.xz
media: ddbridge/mci: protect against out-of-bounds array access in stop()
In stop(), an (unlikely) out-of-bounds write error can occur when setting the demod_in_use element indexed by state->demod to zero, as state->demod isn't checked for being in the range of the array size of demod_in_use, and state->demod maybe carrying the magic 0xff (demod unused) value. Prevent this by checking state->demod not exceeding the array size before setting the element value. To make the code a bit easier to read, replace the magic value and the number of array elements with defines, and use them at a few more places. Detected by CoverityScan, CID#1468550 ("Out-of-bounds write") Thanks to Colin for reporting the problem and providing an initial patch. Fixes: daeeb1319e6f ("media: ddbridge: initial support for MCI-based MaxSX8 cards") Reported-by: Colin Ian King <colin.king@canonical.com> Cc: Ralph Metzler <rjkm@metzlerbros.de> Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/pci/ddbridge/ddbridge-mci.h')
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-mci.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.h b/drivers/media/pci/ddbridge/ddbridge-mci.h
index c4193c5ee095..453dcb9f8208 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.h
@@ -19,6 +19,10 @@
#ifndef _DDBRIDGE_MCI_H_
#define _DDBRIDGE_MCI_H_
+#define MCI_DEMOD_MAX 8
+#define MCI_TUNER_MAX 4
+#define DEMOD_UNUSED (0xFF)
+
#define MCI_CONTROL (0x500)
#define MCI_COMMAND (0x600)
#define MCI_RESULT (0x680)