soc/qualcomm/qcs405: Handle invalid QUP and BLSP

Print an error message and return if an invalid QUP or BLSP is
encountered. This prevents a possible null pointer dereference
of spi_clk.

Change-Id: I374e15ce899c651df9c2d3e0f1ec646e33d4bdb2
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Found-by: Coverity CID 1401086
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34523
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Jacob Garber 2019-07-23 11:46:24 -06:00 committed by Patrick Georgi
parent 767c4b2899
commit 53b4b2850c
1 changed files with 8 additions and 4 deletions

View File

@ -235,12 +235,16 @@ void clock_configure_spi(int blsp, int qup, uint32_t hz)
spi_clk = (struct qcs405_clock *)
&gcc->blsp1_qup4_spi_clk;
break;
default:
printk(BIOS_ERR, "Invalid QUP %d\n", qup);
return;
}
} else if (blsp == 2)
} else if (blsp == 2) {
spi_clk = (struct qcs405_clock *)&gcc->blsp2_qup0_spi_clk;
else
printk(BIOS_ERR, "BLSP%d not supported\n", blsp);
} else {
printk(BIOS_ERR, "BLSP %d not supported\n", blsp);
return;
}
clock_configure(spi_clk, spi_cfg, hz, ARRAY_SIZE(spi_cfg));
}