Skip to content

Commit d3fc02d

Browse files
Dan Carpentergregkh
Dan Carpenter
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 2fda391 commit d3fc02d

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
@@ -1116,12 +1116,12 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
11161116
const struct mipi_dsi_msg *msg)
11171117
{
11181118
struct mtk_dsi *dsi = host_to_dsi(host);
1119-
u32 recv_cnt, i;
1119+
ssize_t recv_cnt;
11201120
u8 read_data[16];
11211121
void *src_addr;
11221122
u8 irq_flag = CMD_DONE_INT_FLAG;
11231123
u32 dsi_mode;
1124-
int ret;
1124+
int ret, i;
11251125

11261126
dsi_mode = readl(dsi->regs + DSI_MODE_CTRL);
11271127
if (dsi_mode & MODE) {
@@ -1170,7 +1170,7 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
11701170
if (recv_cnt)
11711171
memcpy(msg->rx_buf, src_addr, recv_cnt);
11721172

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

11761176
restore_dsi_mode:

0 commit comments

Comments
 (0)