[COMMIT osv master] zfs: fix dangling pointer

0 views
Skip to first unread message

Commit Bot

unread,
Jun 28, 2024, 10:53:47 AM (5 days ago) Jun 28
to osv...@googlegroups.com, Nadav Har'El
From: Nadav Har'El <n...@scylladb.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

zfs: fix dangling pointer

Gcc 14 finds a "dangling pointer" error in the ZFS code. Fix it the
same way that the openzfs developers fixed it in
https://github.com/openzfs/zfs/commit/4840f023afae7c4932c903cf3a436c02c6704e20
Signed-off-by: Nadav Har'El <n...@scylladb.com>

---
diff --git a/bsd/cddl/contrib/opensolaris/lib/libuutil/common/uu_list.c b/bsd/cddl/contrib/opensolaris/lib/libuutil/common/uu_list.c
--- a/bsd/cddl/contrib/opensolaris/lib/libuutil/common/uu_list.c
+++ b/bsd/cddl/contrib/opensolaris/lib/libuutil/common/uu_list.c
@@ -507,14 +507,20 @@ uu_list_walk(uu_list_t *lp, uu_walk_fn_t *func, void *private, uint32_t flags)
}

if (lp->ul_debug || robust) {
- uu_list_walk_t my_walk;
+ uu_list_walk_t *my_walk;
void *e;

- list_walk_init(&my_walk, lp, flags);
+ my_walk = uu_zalloc(sizeof (*my_walk));
+ if (my_walk == NULL)
+ return -1;
+
+ list_walk_init(my_walk, lp, flags);
while (status == UU_WALK_NEXT &&
- (e = uu_list_walk_next(&my_walk)) != NULL)
+ (e = uu_list_walk_next(my_walk)) != NULL)
status = (*func)(e, private);
- list_walk_fini(&my_walk);
+ list_walk_fini(my_walk);
+
+ uu_free(my_walk);
} else {
if (!reverse) {
for (np = lp->ul_null_node.uln_next;
Reply all
Reply to author
Forward
0 new messages