Commit 2803aa74 authored by Chris Wilson's avatar Chris Wilson

drm: Help unconfuse gcc, avoid accidental impossible unsigned comparisons

drivers/gpu/drm/drm_client_modeset.c: In function ‘drm_client_firmware_config’:
./include/linux/bits.h:26:28: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
   __builtin_constant_p((l) > (h)), (l) > (h), 0)))

v2: Add a warning for passing connector_count==0 as this will hit an
infinite loop, so document the invalid parameter.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20200516212330.13633-2-chris@chris-wilson.co.uk
parent 3df6fad4
...@@ -563,7 +563,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, ...@@ -563,7 +563,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
struct drm_client_offset *offsets, struct drm_client_offset *offsets,
bool *enabled, int width, int height) bool *enabled, int width, int height)
{ {
unsigned int count = min_t(unsigned int, connector_count, BITS_PER_LONG); const int count = min_t(unsigned int, connector_count, BITS_PER_LONG);
unsigned long conn_configured, conn_seq, mask; unsigned long conn_configured, conn_seq, mask;
struct drm_device *dev = client->dev; struct drm_device *dev = client->dev;
int i, j; int i, j;
...@@ -577,6 +577,9 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, ...@@ -577,6 +577,9 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
if (!drm_drv_uses_atomic_modeset(dev)) if (!drm_drv_uses_atomic_modeset(dev))
return false; return false;
if (WARN_ON(count <= 0))
return false;
save_enabled = kcalloc(count, sizeof(bool), GFP_KERNEL); save_enabled = kcalloc(count, sizeof(bool), GFP_KERNEL);
if (!save_enabled) if (!save_enabled)
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment