Skip to content

Commit d877bf6

Browse files
Dan Carpentergregkh
authored andcommitted
drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer()
[ Upstream commit dcb166e ] 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 <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Mattijs Korpershoek <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 57a9fb4 commit d877bf6

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
@@ -1108,12 +1108,12 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
11081108
const struct mipi_dsi_msg *msg)
11091109
{
11101110
struct mtk_dsi *dsi = host_to_dsi(host);
1111-
u32 recv_cnt, i;
1111+
ssize_t recv_cnt;
11121112
u8 read_data[16];
11131113
void *src_addr;
11141114
u8 irq_flag = CMD_DONE_INT_FLAG;
11151115
u32 dsi_mode;
1116-
int ret;
1116+
int ret, i;
11171117

11181118
dsi_mode = readl(dsi->regs + DSI_MODE_CTRL);
11191119
if (dsi_mode & MODE) {
@@ -1162,7 +1162,7 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
11621162
if (recv_cnt)
11631163
memcpy(msg->rx_buf, src_addr, recv_cnt);
11641164

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

11681168
restore_dsi_mode:

0 commit comments

Comments
 (0)