The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=f388c311d3d97f5aff47015228033c99b4e6e1eb
commit f388c311d3d97f5aff47015228033c99b4e6e1eb Author: Wuyang Chung <wy-ch...@outlook.com> AuthorDate: 2025-07-13 06:29:59 +0000 Commit: Warner Losh <i...@freebsd.org> CommitDate: 2025-07-23 06:03:23 +0000 GEOM: allocate gp->name immediately after gp Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1765 --- sys/geom/geom_subr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index 41cc115225f9..aba4bf7c44c4 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -381,8 +381,8 @@ g_new_geomf(struct g_class *mp, const char *fmt, ...) sbuf_vprintf(sb, fmt, ap); va_end(ap); sbuf_finish(sb); - gp = g_malloc(sizeof *gp, M_WAITOK | M_ZERO); - gp->name = g_malloc(sbuf_len(sb) + 1, M_WAITOK | M_ZERO); + gp = g_malloc(sizeof *gp + sbuf_len(sb) + 1, M_WAITOK | M_ZERO); + gp->name = (char *)(gp + 1); gp->class = mp; gp->rank = 1; LIST_INIT(&gp->consumer); @@ -420,7 +420,6 @@ g_destroy_geom(struct g_geom *gp) g_cancel_event(gp); LIST_REMOVE(gp, geom); TAILQ_REMOVE(&geoms, gp, geoms); - g_free(gp->name); g_free(gp); }