From: Jani Nikula <jani.nikula@intel.com>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
"Martin Hodo" <martin.hodo@intel.com>,
stable@vger.kernel.org, "Animesh Manna" <animesh.manna@intel.com>,
"Ville Syrjälä" <ville.syrjala@intel.com>,
"Michał Grzelak" <michal.grzelak@intel.com>
Subject: Re: [PATCH v2] drm/i915/bios: range check LFP Data Block panel_type2
Date: Tue, 30 Jun 2026 12:09:06 +0300 [thread overview]
Message-ID: <b8d3d97a0977f8b7a2fcfedbf7d30fa95d322023@intel.com> (raw)
In-Reply-To: <akN8-YNa6kwRVkHk@intel.com>
On Tue, 30 Jun 2026, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Fri, Jun 26, 2026 at 05:01:55PM +0300, Jani Nikula wrote:
>> While the panel_type from LFP Data Block is range checked, panel_type2
>> is not. Add a few helpers for range checking, and use them to not only
>> check panel_type2, but also improve clarity and correctness in the panel
>> type selection.
>>
>> Discovered using AI-assisted static analysis confirmed by Intel Product
>> Security.
>>
>> v2:
>> - Fix commit message typo (Michał)
>> - Add is_panel_type_pnp() (Ville)
>>
>> Reported-by: Martin Hodo <martin.hodo@intel.com>
>> Fixes: 6434cf630086 ("drm/i915/bios: calculate panel type as per child device index in VBT")
>> Cc: <stable@vger.kernel.org> # v6.0+
>> Cc: Animesh Manna <animesh.manna@intel.com>
>> Cc: Ville Syrjälä <ville.syrjala@intel.com>
>> Reviewed-by: Michał Grzelak <michal.grzelak@intel.com> # v1
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>> drivers/gpu/drm/i915/display/intel_bios.c | 36 ++++++++++++++++++-----
>> 1 file changed, 28 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
>> index 15ebadc72b88..97cbae2e547e 100644
>> --- a/drivers/gpu/drm/i915/display/intel_bios.c
>> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
>> @@ -623,6 +623,21 @@ get_lfp_data_tail(const struct bdb_lfp_data *data,
>> return NULL;
>> }
>>
>> +static bool is_panel_type_valid(int panel_type)
>> +{
>> + return panel_type >= 0 && panel_type < 16;
>> +}
>> +
>> +static bool is_panel_type_pnp(int panel_type)
>> +{
>> + return panel_type == 0xff;
>> +}
>> +
>> +static bool is_panel_type_valid_or_pnp(int panel_type)
>> +{
>> + return is_panel_type_valid(panel_type) || is_panel_type_pnp(panel_type);
>> +}
>> +
>> static int opregion_get_panel_type(struct intel_display *display,
>> const struct intel_bios_encoder_data *devdata,
>> const struct drm_edid *drm_edid, bool use_fallback)
>> @@ -640,15 +655,21 @@ static int vbt_get_panel_type(struct intel_display *display,
>> if (!lfp_options)
>> return -1;
>>
>> - if (lfp_options->panel_type > 0xf &&
>> - lfp_options->panel_type != 0xff) {
>> + if (!is_panel_type_valid_or_pnp(lfp_options->panel_type)) {
>> drm_dbg_kms(display->drm, "Invalid VBT panel type 0x%x\n",
>> lfp_options->panel_type);
>> return -1;
>> }
>>
>> - if (devdata && devdata->child.handle == DEVICE_HANDLE_LFP2)
>> + if (devdata && devdata->child.handle == DEVICE_HANDLE_LFP2) {
>> + if (!is_panel_type_valid_or_pnp(lfp_options->panel_type2)) {
>> + drm_dbg_kms(display->drm, "Invalid VBT panel type 2 0x%x\n",
>> + lfp_options->panel_type2);
>> + return -1;
>> + }
>> +
>> return lfp_options->panel_type2;
>> + }
>
> Hmm, this code will always return 'panel_type' if it's valid, even
> for LFP2. That seems wrong, but would need to double check the
> Windows behaviour to be sure...
>
> But that's a separate issue, so this patch is
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Thanks, pushed to din.
BR,
Jani.
>
>>
>> drm_WARN_ON(display->drm,
>> devdata && devdata->child.handle != DEVICE_HANDLE_LFP1);
>> @@ -762,13 +783,12 @@ static int get_panel_type(struct intel_display *display,
>> panel_types[i].name, panel_types[i].panel_type);
>> }
>>
>> - if (panel_types[PANEL_TYPE_OPREGION].panel_type >= 0)
>> + if (is_panel_type_valid(panel_types[PANEL_TYPE_OPREGION].panel_type))
>> i = PANEL_TYPE_OPREGION;
>> - else if (panel_types[PANEL_TYPE_VBT].panel_type == 0xff &&
>> - panel_types[PANEL_TYPE_PNPID].panel_type >= 0)
>> + else if (is_panel_type_pnp(panel_types[PANEL_TYPE_VBT].panel_type) &&
>> + is_panel_type_valid(panel_types[PANEL_TYPE_PNPID].panel_type))
>> i = PANEL_TYPE_PNPID;
>> - else if (panel_types[PANEL_TYPE_VBT].panel_type != 0xff &&
>> - panel_types[PANEL_TYPE_VBT].panel_type >= 0)
>> + else if (is_panel_type_valid(panel_types[PANEL_TYPE_VBT].panel_type))
>> i = PANEL_TYPE_VBT;
>> else
>> i = PANEL_TYPE_FALLBACK;
>> --
>> 2.47.3
--
Jani Nikula, Intel
next prev parent reply other threads:[~2026-06-30 9:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 13:51 [PATCH] drm/i915/bios: range check LFP Data Block panel_type2 Jani Nikula
2026-06-25 15:27 ` Michał Grzelak
2026-06-26 13:37 ` Ville Syrjälä
2026-06-26 14:01 ` [PATCH v2] " Jani Nikula
2026-06-30 8:29 ` Ville Syrjälä
2026-06-30 9:09 ` Jani Nikula [this message]
2026-06-29 13:49 ` ✗ CI.checkpatch: warning for drm/i915/bios: range check LFP Data Block panel_type2 (rev2) Patchwork
2026-06-29 13:50 ` ✓ CI.KUnit: success " Patchwork
2026-06-29 14:59 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-29 18:09 ` ✗ Xe.CI.FULL: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b8d3d97a0977f8b7a2fcfedbf7d30fa95d322023@intel.com \
--to=jani.nikula@intel.com \
--cc=animesh.manna@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=martin.hodo@intel.com \
--cc=michal.grzelak@intel.com \
--cc=stable@vger.kernel.org \
--cc=ville.syrjala@intel.com \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox