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/i915/display: PORT_NONE is not valid

Static analysis issue:

In assert_port_valid, add a check to ensure port != PORT_NONE, as that
is not a valid port. The check must be explicit to prevent a bad bit
shift operation in the general case via short-circuiting. It's not
likely this will ever come up in a real use case, but it's at least
worth guarding against.

It would probably also be pertinent to modify the behavior of the
port_name function to correctly print PORT_NONE in this case, as
currently the port would be reported as 'port @' by the debugger. But
that should be done separately, and given port_name is mostly just a
debug printing helper function anyways, fixing it is a low priority.

v2:
- Conditional check was backwards. Fix it. (Jani)

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patch.msgid.link/20260123152121.7042-2-jonathan.cavitt@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

authored by

Jonathan Cavitt and committed by
Jani Nikula
33978364 8c229b4a

+2 -1
+2 -1
drivers/gpu/drm/i915/display/intel_display.c
··· 7890 7890 7891 7891 bool assert_port_valid(struct intel_display *display, enum port port) 7892 7892 { 7893 - return !drm_WARN(display->drm, !(DISPLAY_RUNTIME_INFO(display)->port_mask & BIT(port)), 7893 + return !drm_WARN(display->drm, 7894 + !(port >= 0 && DISPLAY_RUNTIME_INFO(display)->port_mask & BIT(port)), 7894 7895 "Platform does not support port %c\n", port_name(port)); 7895 7896 } 7896 7897