diff options
author | phk <phk@FreeBSD.org> | 2005-03-26 21:07:35 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2005-03-26 21:07:35 +0000 |
commit | 55543da1eb1bdbfef03df134f78911a727fbc80e (patch) | |
tree | 3f3a0b58c718a28537912b2ca74ebd249d463f28 /sys/geom/geom_subr.c | |
parent | 7f5bd420035b260d059b4fc66175800b183825f8 (diff) | |
download | FreeBSD-src-55543da1eb1bdbfef03df134f78911a727fbc80e.zip FreeBSD-src-55543da1eb1bdbfef03df134f78911a727fbc80e.tar.gz |
fix a "modify after free" bug which is practically impossible to
experience.
Found by: Coverity (id #540 #541)
Diffstat (limited to 'sys/geom/geom_subr.c')
-rw-r--r-- | sys/geom/geom_subr.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index dc2c8ad..4af0d4a 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; } } |