public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/i915/bios: Use get_unaligned_* for VBT block size
@ 2026-01-14  3:01 Kaushlendra Kumar
  2026-01-14  3:11 ` ✓ CI.KUnit: success for drm/i915/bios: Use get_unaligned_* for VBT block size (rev3) Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kaushlendra Kumar @ 2026-01-14  3:01 UTC (permalink / raw)
  To: jani.nikula, rodrigo.vivi, joonas.lahtinen, tursulin, airlied,
	simona
  Cc: intel-gfx, intel-xe, dri-devel, Kaushlendra Kumar

Replace pointer casts with get_unaligned_* helpers for VBT
block size reads. This ensures endianness and alignment
correctness in VBT parsing.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
v2: Fix include ordering, as per review
v3: Update all instances in file, not just _get_blocksize

 drivers/gpu/drm/i915/display/intel_bios.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 4b41068e9e35..91286fafa52b 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -27,6 +27,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/firmware.h>
+#include <linux/unaligned.h>
 
 #include <drm/display/drm_dp_helper.h>
 #include <drm/display/drm_dsc_helper.h>
@@ -85,9 +86,9 @@ static u32 _get_blocksize(const u8 *block_base)
 {
 	/* The MIPI Sequence Block v3+ has a separate size field. */
 	if (*block_base == BDB_MIPI_SEQUENCE && *(block_base + 3) >= 3)
-		return *((const u32 *)(block_base + 4));
+		return get_unaligned_le32(block_base + 4);
 	else
-		return *((const u16 *)(block_base + 1));
+		return get_unaligned_le16(block_base + 1);
 }
 
 /* Get BDB block size give a pointer to data after Block ID and Block Size. */
@@ -1791,9 +1792,9 @@ find_panel_sequence_block(struct intel_display *display,
 
 		current_id = *(data + index);
 		if (sequence->version >= 3)
-			current_size = *((const u32 *)(data + index + 1));
+			current_size = get_unaligned_le32(data + index + 1);
 		else
-			current_size = *((const u16 *)(data + index + 1));
+			current_size = get_unaligned_le16(data + index + 1);
 
 		index += header_size;
 
@@ -1833,7 +1834,7 @@ static int goto_next_sequence(struct intel_display *display,
 			if (index + 4 > total)
 				return 0;
 
-			len = *((const u16 *)(data + index + 2)) + 4;
+			len = get_unaligned_le16(data + index + 2) + 4;
 			break;
 		case MIPI_SEQ_ELEM_DELAY:
 			len = 4;
@@ -1879,7 +1880,7 @@ static int goto_next_sequence_v3(struct intel_display *display,
 	 * includes MIPI_SEQ_ELEM_END byte, excludes the final MIPI_SEQ_END
 	 * byte.
 	 */
-	size_of_sequence = *((const u32 *)(data + index));
+	size_of_sequence = get_unaligned_le32(data + index);
 	index += 4;
 
 	seq_end = index + size_of_sequence;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-14 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-14  3:01 [PATCH v3] drm/i915/bios: Use get_unaligned_* for VBT block size Kaushlendra Kumar
2026-01-14  3:11 ` ✓ CI.KUnit: success for drm/i915/bios: Use get_unaligned_* for VBT block size (rev3) Patchwork
2026-01-14  3:45 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-14 11:11 ` ✓ Xe.CI.Full: " Patchwork
2026-01-14 11:55 ` [PATCH v3] drm/i915/bios: Use get_unaligned_* for VBT block size Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox