From: Ian Rogers <irogers@google.com>
To: Neil Armstrong <neil.armstrong@linaro.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: Jessica Zhang <jesszhan0024@gmail.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>,
Ian Rogers <irogers@google.com>
Subject: [PATCH] drm/panel: dsi-cm: Normalize mipi_dsi_dcs_read/write() return values
Date: Thu, 19 Nov 2026 09:08:18 -0800 [thread overview]
Message-ID: <20261119170818.1528087-1-irogers@google.com> (raw)
When commit d4cf15372868 ("drm/omap: panel-dsi-cm: use DSI helpers")
converted dsicm_dcs_read_1() and dsicm_dcs_write_1() to
mipi_dsi_dcs_read() and mipi_dsi_dcs_write(), all callers in panel-dsi-cm
continued to check 'if (r)' expecting 0 on success and a negative errno on
failure. While OMAP's dsi_vc_dcs_read() populates the buffer and returns 0
on a successful read, mipi_dsi_dcs_read() on standard MIPI DSI hosts and
mipi_dsi_dcs_write() return the positive byte count transferred on
success:
1. A 1-byte DCS read returning 1 causes dsicm_get_id(),
num_dsi_errors_show(), and hw_revision_show() to treat success as a
non-zero return value (exposing 1 byte of uninitialized sysfs buffer).
2. If a DSI host returns 0 without writing the output byte,
dsicm_power_on() and hw_revision_show() read uninitialized stack bytes
(id1, id2, id3).
3. A successful 2-byte DCS write returns 2, causing dsicm_power_on() to
abort at 'if (r) goto err;'.
Normalize both dsicm_dcs_read_1() and dsicm_dcs_write_1() to propagate
negative error codes and return 0 on non-negative return values (handling
both OMAP DSI returning 0 and standard DSI hosts returning byte counts),
zero-initialize *data in dsicm_dcs_read_1(), and zero-initialize id1,
id2, and id3 in hw_revision_show().
Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
-Wconditional-uninitialized enabled; fix and changelog drafted with an AI
coding assistant. Verified with a C unit test and build-tested under
LLVM=1 W=1 (-Werror) and -Wconditional-uninitialized; not tested on DSI
command-mode panel hardware.
Fixes: d4cf15372868 ("drm/omap: panel-dsi-cm: use DSI helpers")
Signed-off-by: Ian Rogers <irogers@google.com>
---
drivers/gpu/drm/panel/panel-dsi-cm.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index ae6e9ffc46cb..1b40fe4f08d8 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -109,12 +109,25 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
{
- return mipi_dsi_dcs_read(ddata->dsi, dcs_cmd, data, 1);
+ ssize_t ret;
+
+ *data = 0;
+ ret = mipi_dsi_dcs_read(ddata->dsi, dcs_cmd, data, 1);
+ if (ret < 0)
+ return ret;
+
+ return 0;
}
static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
{
- return mipi_dsi_dcs_write(ddata->dsi, dcs_cmd, ¶m, 1);
+ ssize_t ret;
+
+ ret = mipi_dsi_dcs_write(ddata->dsi, dcs_cmd, ¶m, 1);
+ if (ret < 0)
+ return ret;
+
+ return 0;
}
static int dsicm_sleep_in(struct panel_drv_data *ddata)
@@ -238,7 +251,7 @@ static ssize_t hw_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_drv_data *ddata = dev_get_drvdata(dev);
- u8 id1, id2, id3;
+ u8 id1 = 0, id2 = 0, id3 = 0;
int r = -ENODEV;
mutex_lock(&ddata->lock);
--
2.56.1.708.g77570a6a1d-goog
reply other threads:[~2026-11-19 17:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261119170818.1528087-1-irogers@google.com \
--to=irogers@google.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=elkin@google.com \
--cc=jesszhan0024@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®