From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0AAB6C43602 for ; Tue, 30 Jun 2026 08:29:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6926510E196; Tue, 30 Jun 2026 08:29:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="CGFr1xg5"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 583F010E194; Tue, 30 Jun 2026 08:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1782808158; x=1814344158; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=+S4eAojz/g8C9jCveAwNs9kiMSikarxTsxTmuHeIXVU=; b=CGFr1xg5MyIpMVK6YMvmK4Qm9Ni4TWZBJPiS6t+zJPEFf5c/MS5Vb94S QQtTmVBqOpjdT1b3tmVqiapYQkNES8YV/7wNZLa+Ht/xaXEFoszYUfzXW dx4iXTJ5QE7atpUNlwghCKM2nWjdNIEvRZ7vJLZlVun6q6QdMQUkeff/9 Di7EER9qKHXzQKrV9RWIM3j4xKjr3iHsPJ4yom4UKrJxvmy8fr4phfe5x gnN0FaraPeYB5enyWiufkfpemCbPLGVYnP5EZZP0UBuaYjrp7IAJZih6Q 1d0D5FtR2Pr+gxPXljsocOya+vhFM3Jd8t2PHrA42NvtRnu0QG/99JP+y A==; X-CSE-ConnectionGUID: 1MU0i914RdSyYkhQyoe9Pg== X-CSE-MsgGUID: jbat7qzwQTymjpqG/dbw6g== X-IronPort-AV: E=McAfee;i="6800,10657,11832"; a="93870429" X-IronPort-AV: E=Sophos;i="6.24,233,1774335600"; d="scan'208";a="93870429" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2026 01:29:18 -0700 X-CSE-ConnectionGUID: 3i2WV8R3Tje1dYOabLX8BQ== X-CSE-MsgGUID: iarQpEQJS2eWHoXc+WEe5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,233,1774335600"; d="scan'208";a="251794796" Received: from mkosciow-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.245.174]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2026 01:29:15 -0700 Date: Tue, 30 Jun 2026 11:29:11 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Jani Nikula Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Martin Hodo , stable@vger.kernel.org, Animesh Manna , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , =?utf-8?Q?Micha=C5=82?= Grzelak Subject: Re: [PATCH v2] drm/i915/bios: range check LFP Data Block panel_type2 Message-ID: References: <20260625135130.1067872-1-jani.nikula@intel.com> <20260626140155.1389655-1-jani.nikula@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260626140155.1389655-1-jani.nikula@intel.com> X-Patchwork-Hint: comment Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs Bertel Jungin Aukio 5, 02600 Espoo, Finland X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" 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 > Fixes: 6434cf630086 ("drm/i915/bios: calculate panel type as per child device index in VBT") > Cc: # v6.0+ > Cc: Animesh Manna > Cc: Ville Syrjälä > Reviewed-by: Michał Grzelak # v1 > Signed-off-by: Jani Nikula > --- > 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ä > > 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 -- Ville Syrjälä Intel