From 41ae864b69991f7e13d5171f54a42c721b297233 Mon Sep 17 00:00:00 2001 From: chenqiuhao1997 Date: Fri, 10 May 2024 23:47:21 +0800 Subject: Replace P2ALIGN with P2ALIGN_TYPED and delete P2ALIGN. In P2ALIGN, the result would be incorrect when align is unsigned integer and x is larger than max value of the type of align. In that case, -(align) would be a positive integer, which means high bits would be zero and finally stay zero after '&' when align is converted to a larger integer type. Reviewed-by: Brian Behlendorf Reviewed-by: Youzhong Yang Signed-off-by: Qiuhao Chen Closes #15940 --- module/os/freebsd/zfs/vdev_geom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/os/freebsd') diff --git a/module/os/freebsd/zfs/vdev_geom.c b/module/os/freebsd/zfs/vdev_geom.c index 9d8897191..38c1d8e9e 100644 --- a/module/os/freebsd/zfs/vdev_geom.c +++ b/module/os/freebsd/zfs/vdev_geom.c @@ -457,7 +457,7 @@ vdev_geom_read_config(struct g_consumer *cp, nvlist_t **configp) ZFS_LOG(1, "Reading config from %s...", pp->name); psize = pp->mediasize; - psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t)); + psize = P2ALIGN_TYPED(psize, sizeof (vdev_label_t), uint64_t); size = sizeof (*vdev_lists[0]) + pp->sectorsize - ((sizeof (*vdev_lists[0]) - 1) % pp->sectorsize) - 1; -- cgit v1.2.3