[PATCH v2] ubi: Fix failure attaching when vid_hdr offset equals to (sub)page size

Richard Weinberger richard at nod.at
Sat Mar 4 09:11:10 PST 2023


----- Ursprüngliche Mail -----
> Von: "chengzhihao1" <chengzhihao1 at huawei.com>
> +	/*
> +	 * Memory allocation for VID header is ubi->vid_hdr_alsize
> +	 * which is described in comments in io.c.
> +	 * Make sure VID header shift + UBI_VID_HDR_SIZE not exceeds
> +	 * ubi->vid_hdr_alsize, so that all vid header operations
> +	 * won't access memory out of bounds.
> +	 */
> +	if ((ubi->vid_hdr_shift + UBI_VID_HDR_SIZE) > ubi->vid_hdr_alsize) {
> +		ubi_err(ubi, "Invalid VID header offset %d, VID header shift(%d)"
> +			" + VID header size(%d) > VID header aligned size(%d).",
> +			ubi->vid_hdr_offset, ubi->vid_hdr_shift,
> +			(int)UBI_VID_HDR_SIZE, ubi->vid_hdr_alsize);

Hmm, why are you casting to int instead of using %zu as format string?

Thanks,
//richard



More information about the linux-mtd mailing list