-----Original Message----- From: Jani Nikula <[email protected]> Sent: Friday, January 23, 2026 1:50 AM To: Cavitt, Jonathan <[email protected]>; [email protected] Cc: Gupta, Saurabhg <[email protected]>; Zuo, Alex <[email protected]>; Cavitt, Jonathan <[email protected]> Subject: Re: [PATCH] drm/i915/display: PORT_NONE is not valid > > On Thu, 22 Jan 2026, Jonathan Cavitt <[email protected]> wrote: > > 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. > > > > Signed-off-by: Jonathan Cavitt <[email protected]> > > --- > > drivers/gpu/drm/i915/display/intel_display.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/i915/display/intel_display.c > > b/drivers/gpu/drm/i915/display/intel_display.c > > index 7491e00e3858..250f31bb5938 100644 > > --- a/drivers/gpu/drm/i915/display/intel_display.c > > +++ b/drivers/gpu/drm/i915/display/intel_display.c > > @@ -7828,7 +7828,8 @@ static bool intel_ddi_crt_present(struct > > intel_display *display) > > > > bool assert_port_valid(struct intel_display *display, enum port port) > > { > > - return !drm_WARN(display->drm, > > !(DISPLAY_RUNTIME_INFO(display)->port_mask & BIT(port)), > > + return !drm_WARN(display->drm, > > + !(port < 0 || DISPLAY_RUNTIME_INFO(display)->port_mask > > & BIT(port)), > > That's a bunch of negatives put together, making one's head spin, but > the innermost part is supposed to be checking if the port is valid, > i.e. BIT(port) is set in ->port_mask. > > This makes "port < 0" another condition for the port being valid, which > is not the case. The port is only valid if > > port >= 0 && DISPLAY_RUNTIME_INFO(display)->port_mask & BIT(port)
Oof... Yeah, that's correct. I fixed it in V2. Thanks for catching that. -Jonathan Cavitt > > BR, > Jani. > > > "Platform does not support port %c\n", > > port_name(port)); > > } > > -- > Jani Nikula, Intel >
