summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/mt8173
diff options
context:
space:
mode:
authorMartin Roth <martinroth@google.com>2016-11-18 09:54:23 -0700
committerNico Huber <nico.h@gmx.de>2016-11-24 00:12:32 +0100
commitba1730b181ed1392d9c6b7ada7ab3bc35b68ffbd (patch)
treec6b202c2b1f25ae627f2f8ecdf2a2d21d3a7d1a0 /src/soc/mediatek/mt8173
parentc8c5ae101aed919959187a0ad33cfbff263ff6a7 (diff)
soc/mediatek/mt8173/spi.c: Change assert to if statement
Asserts are only fatal if CONFIG_FATAL_ASSERTS is enabled in Kconfig. By default this is disabled, so the assert is generally just a printf. Die if someone decides to pass in an invalid bus number for some reason. Addresses coverity issue 1349858 - Out-of-bounds read Signed-off-by: Martin Roth <martinroth@google.com> Change-Id: I9d79bc336cbbfde31f655cfd271f101e7a90ab1b Reviewed-on: https://review.coreboot.org/17484 Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src/soc/mediatek/mt8173')
-rw-r--r--src/soc/mediatek/mt8173/spi.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/soc/mediatek/mt8173/spi.c b/src/soc/mediatek/mt8173/spi.c
index d8639e0ceb..9d56b63027 100644
--- a/src/soc/mediatek/mt8173/spi.c
+++ b/src/soc/mediatek/mt8173/spi.c
@@ -80,8 +80,11 @@ void mtk_spi_init(unsigned int bus, unsigned int pad_select,
unsigned int speed_hz)
{
u32 div, sck_ticks, cs_ticks, reg_val;
- /* mtk spi HW just support bus 0 */
- assert(bus == 0);
+
+ /* mtk spi HW just supports bus 0 */
+ if (bus != 0)
+ die("Error: Only SPI bus 0 is supported.\n");
+
struct mtk_spi_bus *slave = &spi_bus[bus];
struct mtk_spi_regs *regs = slave->regs;