From 0b216b3988e5b7035cd5ed8a9910eacbb3420ce0 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Thu, 12 Dec 2024 11:59:52 +0000 Subject: [PATCH] drm: Validate connector rotation has one bit set in the rotation property Copy the same validation logic as from the plane rotation property. Fixes: 8fec3ff87049 ("drm: Add a rotation parameter to connectors.") Signed-off-by: Dave Stevenson --- drivers/gpu/drm/drm_atomic_uapi.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -812,6 +812,12 @@ static int drm_atomic_connector_set_prop } else if (property == connector->privacy_screen_sw_state_property) { state->privacy_screen_sw_state = val; } else if (property == connector->rotation_property) { + if (!is_power_of_2(val & DRM_MODE_ROTATE_MASK)) { + drm_dbg_atomic(connector->dev, + "[CONNECTOR:%d:%s] bad rotation bitmask: 0x%llx\n", + connector->base.id, connector->name, val); + return -EINVAL; + } state->rotation = val; } else if (connector->funcs->atomic_set_property) { return connector->funcs->atomic_set_property(connector,