* [PATCH] drm/panel: dsi-cm: Normalize mipi_dsi_dcs_read/write() return values
@ 2026-11-19 17:08 Ian Rogers
0 siblings, 0 replies; only message in thread
From: Ian Rogers @ 2026-11-19 17:08 UTC (permalink / raw)
To: Neil Armstrong, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: Jessica Zhang, dri-devel, linux-kernel, llvm, Elkin Cruz, Ian Rogers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 17:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 17:08 [PATCH] drm/panel: dsi-cm: Normalize mipi_dsi_dcs_read/write() return values Ian Rogers
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®