Re: [PATCH 1/1] mtd: ubi: skip programming unused bits in ubi headers

From: Miquel Raynal

Date: Fri Nov 07 2025 - 03:23:39 EST


Hello,

>> > + if (ubi->vid_hdr_shift)
>> > + memset((char *)p, 0xFF, ubi->vid_hdr_alsize - UBI_VID_HDR_SIZE);
>> > + else
>> > + memset((char *)p + UBI_VID_HDR_SIZE, 0xFF, ubi->vid_hdr_alsize - UBI_VID_HDR_SIZE);
>>
>> Here I am reaching the limits of my UBI knowledge, so I would prefer
>> Richard to (in)validate what I am saying, but AFAIU, the VID header can
>> be literally anywhere in the page, not just at the start or end of a
>> subpage, so in the vid_hdr_shift I would expect some extra maths to
>> happen, no?
>
> I understand your point now. If the VID header is not guaranteed to be
> at the start or end of a subpage, then yes, my current logic needs to be
> reworked to cover that case.

I don't know if this is easy to do, but maybe you can memset the whole
buffer before filling it. That would avoid the need to know where the
VID header will be.

Thanks,
Miquèl