Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202603060341.hNj0pl9L-lkp@intel.com/
Fixes: fca11428425e9 ("drm/bridge: waveshare-dsi: Add support for 1..4 DSI data lanes")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Link: https://patch.msgid.link/20260307033245.71666-1-ethantidmore06@gmail.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

authored by

Ethan Tidmore and committed by
Luca Ceresoli
a4697496 27a39e13

+5 -3
+5 -3
drivers/gpu/drm/bridge/waveshare-dsi.c
··· 66 66 dsi->mode_flags = MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_VIDEO | 67 67 MIPI_DSI_CLOCK_NON_CONTINUOUS; 68 68 dsi->format = MIPI_DSI_FMT_RGB888; 69 - dsi->lanes = drm_of_get_data_lanes_count_ep(dev->of_node, 0, 0, 1, 4); 70 - if (dsi->lanes < 0) { 69 + ret = drm_of_get_data_lanes_count_ep(dev->of_node, 0, 0, 1, 4); 70 + if (ret < 0) { 71 71 dev_warn(dev, "Invalid or missing DSI lane count %d, falling back to 2 lanes\n", 72 - dsi->lanes); 72 + ret); 73 73 dsi->lanes = 2; /* Old DT backward compatibility */ 74 + } else { 75 + dsi->lanes = ret; 74 76 } 75 77 76 78 ret = devm_mipi_dsi_attach(dev, dsi);