public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/panel: jadard-jd9365da-h3: Fix signedness bug
@ 2026-04-29  2:49 Ethan Tidmore
  2026-04-30  9:46 ` Neil Armstrong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ethan Tidmore @ 2026-04-29  2:49 UTC (permalink / raw)
  To: Jagan Teki
  Cc: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Linus Walleij,
	Dmitry Baryshkov, dri-devel, linux-kernel, Ethan Tidmore

The function drm_of_get_data_lanes_count_remote() returns negative error
codes and dsi->lanes is an unsigned integer, so the check (dsi->lanes <
0) is always impossible.

Detected by Smatch:
drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c:2959 jadard_dsi_probe()
warn: unsigned 'dsi->lanes' is never less than zero.

Fixes: eb019688f2a97 ("drm/panel: jadard-jd9365da-h3: support variable DSI configuration")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c b/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c
index 7157b1299bfd..f6b04de1182e 100644
--- a/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c
+++ b/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c
@@ -2955,9 +2955,11 @@ static int jadard_dsi_probe(struct mipi_dsi_device *dsi)
 	dsi->format = desc->format;
 	dsi->lanes = desc->lanes;
 	if (!dsi->lanes) {
-		dsi->lanes = drm_of_get_data_lanes_count_remote(dsi->dev.of_node, 0, -1, 2, 4);
-		if (dsi->lanes < 0)
-			return dsi->lanes;
+		ret = drm_of_get_data_lanes_count_remote(dsi->dev.of_node, 0, -1, 2, 4);
+		if (ret < 0)
+			return ret;
+		dsi->lanes = ret;
+
 		if (dsi->lanes == 4) {
 			if (!desc->mode_4ln) {
 				dev_err(&dsi->dev, "4-lane config is not supported\n");
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/panel: jadard-jd9365da-h3: Fix signedness bug
  2026-04-29  2:49 [PATCH] drm/panel: jadard-jd9365da-h3: Fix signedness bug Ethan Tidmore
@ 2026-04-30  9:46 ` Neil Armstrong
  2026-05-05  2:04 ` Claude review: " Claude Code Review Bot
  2026-05-05  2:04 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2026-04-30  9:46 UTC (permalink / raw)
  To: Ethan Tidmore, Jagan Teki
  Cc: Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Linus Walleij,
	Dmitry Baryshkov, dri-devel, linux-kernel

On 4/29/26 04:49, Ethan Tidmore wrote:
> The function drm_of_get_data_lanes_count_remote() returns negative error
> codes and dsi->lanes is an unsigned integer, so the check (dsi->lanes <
> 0) is always impossible.
> 
> Detected by Smatch:
> drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c:2959 jadard_dsi_probe()
> warn: unsigned 'dsi->lanes' is never less than zero.
> 
> Fixes: eb019688f2a97 ("drm/panel: jadard-jd9365da-h3: support variable DSI configuration")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>   drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c b/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c
> index 7157b1299bfd..f6b04de1182e 100644
> --- a/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c
> +++ b/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c
> @@ -2955,9 +2955,11 @@ static int jadard_dsi_probe(struct mipi_dsi_device *dsi)
>   	dsi->format = desc->format;
>   	dsi->lanes = desc->lanes;
>   	if (!dsi->lanes) {
> -		dsi->lanes = drm_of_get_data_lanes_count_remote(dsi->dev.of_node, 0, -1, 2, 4);
> -		if (dsi->lanes < 0)
> -			return dsi->lanes;
> +		ret = drm_of_get_data_lanes_count_remote(dsi->dev.of_node, 0, -1, 2, 4);
> +		if (ret < 0)
> +			return ret;
> +		dsi->lanes = ret;
> +
>   		if (dsi->lanes == 4) {
>   			if (!desc->mode_4ln) {
>   				dev_err(&dsi->dev, "4-lane config is not supported\n");

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Claude review: drm/panel: jadard-jd9365da-h3: Fix signedness bug
  2026-04-29  2:49 [PATCH] drm/panel: jadard-jd9365da-h3: Fix signedness bug Ethan Tidmore
  2026-04-30  9:46 ` Neil Armstrong
  2026-05-05  2:04 ` Claude review: " Claude Code Review Bot
@ 2026-05-05  2:04 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-05-05  2:04 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/panel: jadard-jd9365da-h3: Fix signedness bug
Author: Ethan Tidmore <ethantidmore06@gmail.com>
Patches: 2
Reviewed: 2026-05-05T12:04:55.315030

---

This is a single-patch fix for a real signedness bug detected by Smatch. The function `drm_of_get_data_lanes_count_remote()` returns `int` (including negative error codes), but its return value was being stored directly into `dsi->lanes`, which is `unsigned int`. This made the subsequent `dsi->lanes < 0` check dead code — it could never be true. The fix is correct, minimal, and follows standard kernel patterns for handling this class of bug.

The patch is suitable for merging. One minor nit below.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Claude review: drm/panel: jadard-jd9365da-h3: Fix signedness bug
  2026-04-29  2:49 [PATCH] drm/panel: jadard-jd9365da-h3: Fix signedness bug Ethan Tidmore
  2026-04-30  9:46 ` Neil Armstrong
@ 2026-05-05  2:04 ` Claude Code Review Bot
  2026-05-05  2:04 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-05-05  2:04 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Correctness: Good.** The fix properly introduces a signed `int ret` intermediate variable to catch the negative error code before assigning to the unsigned `dsi->lanes`:

```c
-		dsi->lanes = drm_of_get_data_lanes_count_remote(dsi->dev.of_node, 0, -1, 2, 4);
-		if (dsi->lanes < 0)
-			return dsi->lanes;
+		ret = drm_of_get_data_lanes_count_remote(dsi->dev.of_node, 0, -1, 2, 4);
+		if (ret < 0)
+			return ret;
+		dsi->lanes = ret;
```

This is the standard kernel pattern: store into a signed variable, check for error, then assign to the unsigned field only on success. The `ret` variable should already be declared in this probe function (standard for probe functions returning `int`).

**Commit message: Good.** The message clearly explains the bug, includes the Smatch warning output, and has an appropriate `Fixes:` tag referencing the commit that introduced the problematic code.

**Minor nit:** There's a spurious blank line added between `dsi->lanes = ret;` and `if (dsi->lanes == 4)`:

```c
+		dsi->lanes = ret;
+
 		if (dsi->lanes == 4) {
```

This is not wrong, but the original code had no blank line here, and the `if (dsi->lanes == 4)` check is logically tightly coupled to the lanes assignment. It would be slightly cleaner without the extra blank line, though this is a very minor style point and not worth blocking the patch over.

**Verdict:** Reviewed-by worthy. The fix is correct and addresses a real bug where error codes from `drm_of_get_data_lanes_count_remote()` would be silently converted to a large unsigned value, causing the driver to proceed with a bogus lane count instead of returning an error.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-05  2:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29  2:49 [PATCH] drm/panel: jadard-jd9365da-h3: Fix signedness bug Ethan Tidmore
2026-04-30  9:46 ` Neil Armstrong
2026-05-05  2:04 ` Claude review: " Claude Code Review Bot
2026-05-05  2:04 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox