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>
This commit is contained in:
Jacob Garber 2019-07-23 15:30:45 -06:00 committed by Patrick Georgi
parent bd00fb1366
commit 9777048e92
1 changed files with 2 additions and 2 deletions

View File

@ -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, 0, DSI_PKT_LEN_0_1);
tegra_dsi_writel(dsi, bytes << 16, DSI_PKT_LEN_2_3); tegra_dsi_writel(dsi, (u32)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_4_5);
tegra_dsi_writel(dsi, 0, DSI_PKT_LEN_6_7); tegra_dsi_writel(dsi, 0, DSI_PKT_LEN_6_7);
value = MIPI_DCS_WRITE_MEMORY_START << 8 | value = MIPI_DCS_WRITE_MEMORY_START << 8 |