Skip to contentSkip to conversation

drm/panel: jadard-jd9365da-h3: Fix signedness bug

PATCH Applied Ethan Tidmore 2 participants 3 messages Apr 29 – May 5

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/panel: jadard-jd9365da-h3: Fix signedness bug

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")
---
 drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c +5 -3
index 7157b1299bfd..f6b04de1182e 100644
@@ -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");
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · 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")
---
  drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c +0 -1
index 7157b1299bfd..f6b04de1182e 100644
@@ -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);

drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c static int jadard_dsi_probe(struct mipi_dsi_device *dsi) · line 2965

Quoted 10 lines
drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c +5 -2
-		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");

Thanks,
Neil

maintainer Applied
#2 lore raw
In reply to Ethan Tidmore

Hi,

Quoted 9 lines · 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.

[...]

Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)

[1/1] drm/panel: jadard-jd9365da-h3: Fix signedness bug

      https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/faddee87a933898139f5aa9e76bdca345936b538
Signature · 1 line
Neil