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

Miquel Raynal miquel.raynal at bootlin.com
Fri Nov 14 00:31:47 PST 2025


Hi Cheng Ming,

> @@ -1150,6 +1152,14 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
>  		return -EROFS;
>  	}
>  
> +	if (ubi->vid_hdr_shift) {
> +		memset((char *)p, 0xFF, ubi->vid_hdr_shift);
> +		memset((char *)p + ubi->vid_hdr_shift + UBI_VID_HDR_SIZE, 0xFF,
> +		       ubi->vid_hdr_alsize - (ubi->vid_hdr_shift + UBI_VID_HDR_SIZE));
> +	} else {
> +		memset((char *)p + UBI_VID_HDR_SIZE, 0xFF, ubi->vid_hdr_alsize - UBI_VID_HDR_SIZE);
> +	}
> +

Is it not possible to memset() the buffer before writing the VID header?
I haven't found quickly a good place to do that, so in any case,

Reviewed-by: Miquel Raynal <miquel.raynal at bootlin.com>

Thanks,
Miquèl



More information about the linux-mtd mailing list