Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26A5038F233; Sat, 17 Oct 2026 17:43:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792259040; cv=none; b=YRGY1CGU/8zilKVFatnwgBiQzB8GHrwMcGGViVLLBjzZvsErSx7lVk/LOEjbWE6ymFQbLHJTyvkcklSH+uCUbdKeTWdNEdRf82xNLzW/Ao0GHRe542QeJ/DtlHQ8oHvAXjoxeHrdRi7W8pg++KLtbgstV3DHXrxhJbSC9B0NNdA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792259040; c=relaxed/simple; bh=4dOqGsyB9Q2/9s1tdvF3WqMB1m/cuv/S4aqAQsTp6AE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JvzCjATaxA18+Kl/CyC+JBCM4Zgx+mfzciKov5WJcE29j1WPw9GJXj6WeVQXhv4MZzMEPTcfMZtgrOPDp5YoNeu0LFjOBKLbU5cSruoBIhFQ1hhSWEeCUePS/dyMhrzI6ZCvElPBdwVXocjzQUG5tiTnSWFEPikMVBj3BHe6dy0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JL6oS/0u; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="JL6oS/0u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B30B1F000C4; Sat, 17 Oct 2026 17:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792259039; bh=91TPZaCEsGxgZ4B0bEutVFuZw2hGTIA7OBfeUmJaF/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JL6oS/0uzYLIQvHlqRlkOcBJQf2CVOwETIZUGPD120tYoveNt/Nkdm+DEGnEY0pku swsDIJj5hs7cLJbQWMAuBPq/MPpPQLtIIyjiwDiPXiCnhOUNhT9W9al0ZKnS/N5ccj xwxoZIexOIWCBgJbRVCUY0JUg/Y2zn8ZOCLdhLg0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Martin Hodo , Animesh Manna , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Jani Nikula , Joonas Lahtinen , Sasha Levin , =?UTF-8?q?Micha=C5=82=20Grzelak?= Subject: [PATCH 6.6 1082/1674] drm/i915/bios: range check LFP Data Block panel_type2 Date: Sat, 17 Oct 2026 17:55:54 +0200 Message-ID: <20261017160458.900204897@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jani Nikula [ Upstream commit 2084503f2d087bf956198e7f6eb25b03a7049cb2 ] 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: stable@vger.kernel.org # v6.0+ Cc: Animesh Manna Cc: Ville Syrjälä Reviewed-by: Michał Grzelak # v1 Reviewed-by: Ville Syrjälä Link: https://patch.msgid.link/20260626140155.1389655-1-jani.nikula@intel.com Signed-off-by: Jani Nikula (cherry picked from commit c9ebe5d2f25729d6cfbbb1235d640bf67f9275df) Signed-off-by: Joonas Lahtinen Signed-off-by: Sasha Levin --- 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 27d1c49b46ec4..0b7522ad8f3ea 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -617,6 +617,21 @@ static void dump_pnp_id(struct drm_i915_private *i915, pnp_id->mfg_week, pnp_id->mfg_year + 1990); } +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 drm_i915_private *i915, const struct intel_bios_encoder_data *devdata, const struct drm_edid *drm_edid, bool use_fallback) @@ -634,15 +649,21 @@ static int vbt_get_panel_type(struct drm_i915_private *i915, if (!lvds_options) return -1; - if (lvds_options->panel_type > 0xf && - lvds_options->panel_type != 0xff) { + if (!is_panel_type_valid_or_pnp(lvds_options->panel_type)) { drm_dbg_kms(&i915->drm, "Invalid VBT panel type 0x%x\n", lvds_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(lvds_options->panel_type2)) { + drm_dbg_kms(&i915->drm, "Invalid VBT panel type 2 0x%x\n", + lvds_options->panel_type2); + return -1; + } + return lvds_options->panel_type2; + } drm_WARN_ON(&i915->drm, devdata && devdata->child.handle != DEVICE_HANDLE_LFP1); @@ -755,13 +776,12 @@ static int get_panel_type(struct drm_i915_private *i915, 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.53.0