]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 8 Jan 2025 09:35:57 +0000 (12:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:39:16 +0000 (14:39 +0200)
[ 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: 81cc7e51c4f1 ("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>
drivers/gpu/drm/mediatek/mtk_dsi.c

index b9b7fd08b7d7e9c3322e6c8d59e735b1781a3a66..88f3dfeb4731d305334f3ce94c8c90ea52b6eb08 100644 (file)
@@ -1108,12 +1108,12 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
                                     const struct mipi_dsi_msg *msg)
 {
        struct mtk_dsi *dsi = host_to_dsi(host);
-       u32 recv_cnt, i;
+       ssize_t recv_cnt;
        u8 read_data[16];
        void *src_addr;
        u8 irq_flag = CMD_DONE_INT_FLAG;
        u32 dsi_mode;
-       int ret;
+       int ret, i;
 
        dsi_mode = readl(dsi->regs + DSI_MODE_CTRL);
        if (dsi_mode & MODE) {
@@ -1162,7 +1162,7 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
        if (recv_cnt)
                memcpy(msg->rx_buf, src_addr, recv_cnt);
 
-       DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n",
+       DRM_INFO("dsi get %zd byte data from the panel address(0x%x)\n",
                 recv_cnt, *((u8 *)(msg->tx_buf)));
 
 restore_dsi_mode: