From 296d283c837c6ae85bbf8e8603a1e8250cc30e95 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 26 Mar 2005 21:07:35 +0000 Subject: [PATCH] fix a "modify after free" bug which is practically impossible to experience. Found by: Coverity (id #540 #541) --- sys/geom/geom_subr.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index dc2c8ad4701a..4af0d4a129f1 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -82,10 +82,11 @@ g_load_class(void *arg, int flag) hh = arg; mp = hh->mp; - if (hh->post) + hh->error = 0; + if (hh->post) { g_free(hh); - else - hh->error = 0; + hh = NULL; + } g_trace(G_T_TOPOLOGY, "g_load_class(%s)", mp->name); KASSERT(mp->name != NULL && *mp->name != '\0', ("GEOM class has no name")); @@ -93,12 +94,14 @@ g_load_class(void *arg, int flag) if (mp2 == mp) { printf("The GEOM class %s is already loaded.\n", mp2->name); - hh->error = EEXIST; + if (hh != NULL) + hh->error = EEXIST; return; } else if (strcmp(mp2->name, mp->name) == 0) { printf("A GEOM class %s is already loaded.\n", mp2->name); - hh->error = EEXIST; + if (hh != NULL) + hh->error = EEXIST; return; } }