Re: [PATCH RESEND] drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Dan:

Dan Carpenter <dan.carpenter@xxxxxxxxxx> 於 2025年1月8日 週三 下午5:36寫道:
>
> 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.

Applied to mediatek-drm-next [1], thanks.

[1] https://web.git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

>
> Fixes: 81cc7e51c4f1 ("drm/mediatek: Allow commands to be sent during video mode")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/r/202412210801.iADw0oIH-lkp@xxxxxxxxx/
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Reviewed-by: Mattijs Korpershoek <mkorpershoek@xxxxxxxxxxxx>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
> ---
> I sent this patch earlier:
> https://lore.kernel.org/all/Y%2FyBC4yxTs+Po0TG@kili/
> but it wasn't applied.  I've changed the commit message a bit and added
> new tags.
>
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index d871b1dba083..0acfda47f002 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -1015,12 +1015,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) {
> @@ -1069,7 +1069,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:
> --
> 2.45.2
>




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux