Skip to content

Commit d57c8a7

Browse files
Dan Carpentersmb49
authored andcommitted
drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer()
BugLink: https://bugs.launchpad.net/bugs/2110173 [ Upstream commit dcb166ee43c3d594e7b73a24f6e8cf5663eeff2c ] There is a type bug because the return statement: return ret < 0 ? ret : recv_cnt; The issue is that ret is an int, recv_cnt is a u32 and the function returns ssize_t, which is a signed long. The way that the type promotion works is that the negative error codes are first cast to u32 and then to signed long. The error codes end up being positive instead of negative and the callers treat them as success. Fixes: 81cc7e5 ("drm/mediatek: Allow commands to be sent during video mode") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/r/202412210801.iADw0oIH-lkp@intel.com/ Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: CK Hu <ck.hu@mediatek.com> Link: https://patchwork.kernel.org/project/dri-devel/patch/b754a408-4f39-4e37-b52d-7706c132e27f@stanley.mountain/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Noah Wager <noah.wager@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent ecf2f97 commit d57c8a7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/mediatek/mtk_dsi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,12 +1027,12 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
10271027
const struct mipi_dsi_msg *msg)
10281028
{
10291029
struct mtk_dsi *dsi = host_to_dsi(host);
1030-
u32 recv_cnt, i;
1030+
ssize_t recv_cnt;
10311031
u8 read_data[16];
10321032
void *src_addr;
10331033
u8 irq_flag = CMD_DONE_INT_FLAG;
10341034
u32 dsi_mode;
1035-
int ret;
1035+
int ret, i;
10361036

10371037
dsi_mode = readl(dsi->regs + DSI_MODE_CTRL);
10381038
if (dsi_mode & MODE) {
@@ -1081,7 +1081,7 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
10811081
if (recv_cnt)
10821082
memcpy(msg->rx_buf, src_addr, recv_cnt);
10831083

1084-
DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n",
1084+
DRM_INFO("dsi get %zd byte data from the panel address(0x%x)\n",
10851085
recv_cnt, *((u8 *)(msg->tx_buf)));
10861086

10871087
restore_dsi_mode:

0 commit comments

Comments
 (0)