On Wed, 14 Jan 2026, Kaushlendra Kumar <[email protected]> wrote: > 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 <[email protected]>
Reviewed-by: Jani Nikula <[email protected]> > --- > 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; -- Jani Nikula, Intel
