From: Dan Carpenter <dan.carpenter@oracle.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Rob Clark <robdclark@gmail.com>, Hai Li <hali@codeaurora.org>,
Sean Paul <sean@poorly.run>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
Abhinav Kumar <abhinavk@codeaurora.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Jonathan Marek <jonathan@marek.ca>,
Yangtao Li <tiny.windzz@gmail.com>,
Nicolas Boichat <drinkcat@chromium.org>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 3/3] drm/msm/dsi: fix signedness bug in msm_dsi_host_cmd_rx()
Date: Mon, 4 Oct 2021 09:45:46 +0300 [thread overview]
Message-ID: <20211004064546.GR2048@kadam> (raw)
In-Reply-To: <a61cad95-d81d-6f6d-33d4-f5259d9814cb@linaro.org>
On Sat, Oct 02, 2021 at 01:59:56AM +0300, Dmitry Baryshkov wrote:
> On 01/10/2021 15:36, Dan Carpenter wrote:
> > The "msg->tx_len" variable is type size_t so if dsi_cmds2buf_tx()
> > returns a negative error code that it type promoted to a high positive
> > value and treat as a success. The second problem with this code is
> > that it can return meaningless positive values on error.
>
> It looks to me that this piece of code is not fully correct at all.
> dsi_cmds2bus_tx would return the size of DSI packet, not the size of the DSI
> buffer.
Ugh... I misread what you were saying. I was thinking I could just
check for negatives. This sounds like struct_size() thing?
>
> Could you please be more specific, which 'meaningless positive values' were
> you receiving?
>
Returning any positive values at this point is a bug. It's supposed to
return the number of bytes that were recieved.
And there is another bug as well:
drivers/gpu/drm/msm/dsi/dsi_host.c
1370 static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host,
1371 const struct mipi_dsi_msg *msg)
1372 {
1373 int len, ret;
1374 int bllp_len = msm_host->mode->hdisplay *
1375 dsi_get_bpp(msm_host->format) / 8;
1376
1377 len = dsi_cmd_dma_add(msm_host, msg);
1378 if (!len) {
The dsi_cmd_dma_add() returns negative error codes so this check should
be "if (len <= 0) {".
1379 pr_err("%s: failed to add cmd type = 0x%x\n",
1380 __func__, msg->type);
1381 return -EINVAL;
1382 }
1383
I'm not sure about the size of "the DSI packet" Could you handle this
one and give me a Reported-by tag? That's probably simpler than another
back and forth on email.
regards,
dan carpenter
next prev parent reply other threads:[~2021-10-04 6:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 12:33 [PATCH 1/3] drm/msm/dsi: Fix an error code in msm_dsi_modeset_init() Dan Carpenter
2021-10-01 12:34 ` [PATCH 2/3] drm/msm/dsi: fix off by one in dsi_bus_clk_enable error handling Dan Carpenter
2021-10-01 22:47 ` Dmitry Baryshkov
2021-10-01 12:36 ` [PATCH 3/3] drm/msm/dsi: fix signedness bug in msm_dsi_host_cmd_rx() Dan Carpenter
2021-10-01 22:59 ` Dmitry Baryshkov
2021-10-04 6:18 ` Dan Carpenter
2021-10-04 6:45 ` Dan Carpenter [this message]
2021-10-01 22:45 ` [PATCH 1/3] drm/msm/dsi: Fix an error code in msm_dsi_modeset_init() Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211004064546.GR2048@kadam \
--to=dan.carpenter@oracle.com \
--cc=abhinavk@codeaurora.org \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=drinkcat@chromium.org \
--cc=freedreno@lists.freedesktop.org \
--cc=hali@codeaurora.org \
--cc=jonathan@marek.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=robdclark@gmail.com \
--cc=sean@poorly.run \
--cc=tiny.windzz@gmail.com \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).