Commit a4697496 authored by Ethan Tidmore's avatar Ethan Tidmore Committed by Luca Ceresoli
Browse files

drm/bridge: waveshare-dsi: Fix signedness bug



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

Make the return value of drm_of_get_data_lanes_count_ep() be assigned to
ret, check for error, and then assign dsi->lanes to ret.

Detected by Smatch:
drivers/gpu/drm/bridge/waveshare-dsi.c:70 ws_bridge_attach_dsi() warn:
unsigned 'dsi->lanes' is never less than zero.

Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202603060341.hNj0pl9L-lkp@intel.com/


Fixes: fca11428 ("drm/bridge: waveshare-dsi: Add support for 1..4 DSI data lanes")
Signed-off-by: default avatarEthan Tidmore <ethantidmore06@gmail.com>
Reviewed-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: default avatarMarek Vasut <marek.vasut+renesas@mailbox.org>
Link: https://patch.msgid.link/20260307033245.71666-1-ethantidmore06@gmail.com


Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
parent 27a39e13
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -66,11 +66,13 @@ static int ws_bridge_attach_dsi(struct ws_bridge *ws)
	dsi->mode_flags = MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_VIDEO |
			  MIPI_DSI_CLOCK_NON_CONTINUOUS;
	dsi->format = MIPI_DSI_FMT_RGB888;
	dsi->lanes = drm_of_get_data_lanes_count_ep(dev->of_node, 0, 0, 1, 4);
	if (dsi->lanes < 0) {
	ret = drm_of_get_data_lanes_count_ep(dev->of_node, 0, 0, 1, 4);
	if (ret < 0) {
		dev_warn(dev, "Invalid or missing DSI lane count %d, falling back to 2 lanes\n",
			 dsi->lanes);
			 ret);
		dsi->lanes = 2;	/* Old DT backward compatibility */
	} else {
		dsi->lanes = ret;
	}

	ret = devm_mipi_dsi_attach(dev, dsi);