summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-07-23 15:30:45 -0600
committerPatrick Georgi <pgeorgi@google.com>2019-07-25 16:04:27 +0000
commit9777048e9209c1f59d225427b28513984216fd01 (patch)
tree27e13f0a2d7a126c4969c981e886f6b4accd2bac
parentbd00fb13663560fa1a204ae8d324a603370e19ff (diff)
downloadcoreboot-9777048e9209c1f59d225427b28513984216fd01.tar.xz
soc/nvidia/tegra210: Prevent unintended sign extension
The perennial problem with u16 << 16 strikes again - the u16 is implicitly promoted to an int before the shift, which will then become negative if the highest bit of the u16 was set. Normally this isn't much of a problem, but in this case tegra_dsi_writel() expects a 64 bit integer for that argument, and so it will be sign-extended to a very large unsigned integer if it is negative. Cast bytes to a u32 beforehand to prevent the implicit promotion and thus this problem. Change-Id: Iaf0fb1040ccafafde0093e9bb192c802b86cb2ac Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 1294800 Reviewed-on: https://review.coreboot.org/c/coreboot/+/34529 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--src/soc/nvidia/tegra210/dsi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/soc/nvidia/tegra210/dsi.c b/src/soc/nvidia/tegra210/dsi.c
index a383ff208c..7d54c9e8ac 100644
--- a/src/soc/nvidia/tegra210/dsi.c
+++ b/src/soc/nvidia/tegra210/dsi.c
@@ -380,8 +380,8 @@ static int tegra_dsi_configure(struct tegra_dsi *dsi, unsigned int pipe,
}
tegra_dsi_writel(dsi, 0, DSI_PKT_LEN_0_1);
- tegra_dsi_writel(dsi, bytes << 16, DSI_PKT_LEN_2_3);
- tegra_dsi_writel(dsi, bytes << 16, DSI_PKT_LEN_4_5);
+ tegra_dsi_writel(dsi, (u32)bytes << 16, DSI_PKT_LEN_2_3);
+ tegra_dsi_writel(dsi, (u32)bytes << 16, DSI_PKT_LEN_4_5);
tegra_dsi_writel(dsi, 0, DSI_PKT_LEN_6_7);
value = MIPI_DCS_WRITE_MEMORY_START << 8 |