summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/cache/g_cache.c37
-rw-r--r--sys/geom/concat/g_concat.c2
-rw-r--r--sys/geom/eli/g_eli.c2
-rw-r--r--sys/geom/journal/g_journal.c1
-rw-r--r--sys/geom/mountver/g_mountver.c35
-rw-r--r--sys/geom/multipath/g_multipath.c14
-rw-r--r--sys/geom/sched/g_sched.c34
-rw-r--r--sys/geom/shsec/g_shsec.c2
-rw-r--r--sys/geom/stripe/g_stripe.c2
9 files changed, 17 insertions, 112 deletions
diff --git a/sys/geom/cache/g_cache.c b/sys/geom/cache/g_cache.c
index 01c7873..ca05f14 100644
--- a/sys/geom/cache/g_cache.c
+++ b/sys/geom/cache/g_cache.c
@@ -501,12 +501,6 @@ g_cache_create(struct g_class *mp, struct g_provider *pp,
}
gp = g_new_geomf(mp, md->md_name);
- if (gp == NULL) {
- G_CACHE_DEBUG(0, "Cannot create geom %s.", md->md_name);
- return (NULL);
- }
- gp->softc = NULL; /* for a moment */
-
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
sc->sc_type = type;
sc->sc_bshift = bshift;
@@ -527,10 +521,6 @@ g_cache_create(struct g_class *mp, struct g_provider *pp,
gp->dumpconf = g_cache_dumpconf;
newpp = g_new_providerf(gp, "cache/%s", gp->name);
- if (newpp == NULL) {
- G_CACHE_DEBUG(0, "Cannot create provider cache/%s.", gp->name);
- goto fail;
- }
newpp->sectorsize = pp->sectorsize;
newpp->mediasize = pp->mediasize;
if (type == G_CACHE_TYPE_AUTOMATIC)
@@ -538,35 +528,20 @@ g_cache_create(struct g_class *mp, struct g_provider *pp,
sc->sc_tail = BNO2OFF(OFF2BNO(newpp->mediasize, sc), sc);
cp = g_new_consumer(gp);
- if (cp == NULL) {
- G_CACHE_DEBUG(0, "Cannot create consumer for %s.", gp->name);
- goto fail;
- }
if (g_attach(cp, pp) != 0) {
G_CACHE_DEBUG(0, "Cannot attach to provider %s.", pp->name);
- goto fail;
+ g_destroy_consumer(cp);
+ g_destroy_provider(newpp);
+ mtx_destroy(&sc->sc_mtx);
+ g_free(sc);
+ g_destroy_geom(gp);
+ return (NULL);
}
g_error_provider(newpp, 0);
G_CACHE_DEBUG(0, "Device %s created.", gp->name);
callout_reset(&sc->sc_callout, g_cache_timeout * hz, g_cache_go, sc);
return (gp);
-fail:
- if (cp != NULL) {
- if (cp->provider != NULL)
- g_detach(cp);
- g_destroy_consumer(cp);
- }
- if (newpp != NULL)
- g_destroy_provider(newpp);
- if (gp != NULL) {
- if (gp->softc != NULL) {
- mtx_destroy(&sc->sc_mtx);
- g_free(gp->softc);
- }
- g_destroy_geom(gp);
- }
- return (NULL);
}
static int
diff --git a/sys/geom/concat/g_concat.c b/sys/geom/concat/g_concat.c
index 10ee571..54e0fe0 100644
--- a/sys/geom/concat/g_concat.c
+++ b/sys/geom/concat/g_concat.c
@@ -547,8 +547,6 @@ g_concat_create(struct g_class *mp, const struct g_concat_metadata *md,
}
}
gp = g_new_geomf(mp, "%s", md->md_name);
- gp->softc = NULL; /* for a moment */
-
sc = malloc(sizeof(*sc), M_CONCAT, M_WAITOK | M_ZERO);
gp->start = g_concat_start;
gp->spoiled = g_concat_orphan;
diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c
index 8edd147..8b22ee5 100644
--- a/sys/geom/eli/g_eli.c
+++ b/sys/geom/eli/g_eli.c
@@ -682,8 +682,6 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *bpp,
G_ELI_DEBUG(1, "Creating device %s%s.", bpp->name, G_ELI_SUFFIX);
gp = g_new_geomf(mp, "%s%s", bpp->name, G_ELI_SUFFIX);
- gp->softc = NULL; /* for a moment */
-
sc = malloc(sizeof(*sc), M_ELI, M_WAITOK | M_ZERO);
gp->start = g_eli_start;
/*
diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c
index 906a1e4..254ba92 100644
--- a/sys/geom/journal/g_journal.c
+++ b/sys/geom/journal/g_journal.c
@@ -2097,7 +2097,6 @@ g_journal_worker(void *arg)
gp = sc->sc_geom;
g_topology_lock();
pp = g_new_providerf(gp, "%s.journal", sc->sc_name);
- KASSERT(pp != NULL, ("Cannot create %s.journal.", sc->sc_name));
pp->mediasize = sc->sc_mediasize;
/*
* There could be a problem when data provider and journal providers
diff --git a/sys/geom/mountver/g_mountver.c b/sys/geom/mountver/g_mountver.c
index bf2e8a6..c653090 100644
--- a/sys/geom/mountver/g_mountver.c
+++ b/sys/geom/mountver/g_mountver.c
@@ -248,10 +248,6 @@ g_mountver_create(struct gctl_req *req, struct g_class *mp, struct g_provider *p
}
}
gp = g_new_geomf(mp, name);
- if (gp == NULL) {
- gctl_error(req, "Cannot create geom %s.", name);
- return (ENOMEM);
- }
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
mtx_init(&sc->sc_mtx, "gmountver", NULL, MTX_DEF);
TAILQ_INIT(&sc->sc_queue);
@@ -263,20 +259,10 @@ g_mountver_create(struct gctl_req *req, struct g_class *mp, struct g_provider *p
gp->dumpconf = g_mountver_dumpconf;
newpp = g_new_providerf(gp, gp->name);
- if (newpp == NULL) {
- gctl_error(req, "Cannot create provider %s.", name);
- error = ENOMEM;
- goto fail;
- }
newpp->mediasize = pp->mediasize;
newpp->sectorsize = pp->sectorsize;
cp = g_new_consumer(gp);
- if (cp == NULL) {
- gctl_error(req, "Cannot create consumer for %s.", gp->name);
- error = ENOMEM;
- goto fail;
- }
error = g_attach(cp, pp);
if (error != 0) {
gctl_error(req, "Cannot attach to provider %s.", pp->name);
@@ -303,20 +289,13 @@ g_mountver_create(struct gctl_req *req, struct g_class *mp, struct g_provider *p
G_MOUNTVER_DEBUG(0, "Device %s created.", gp->name);
return (0);
fail:
- if (sc->sc_provider_name != NULL)
- g_free(sc->sc_provider_name);
- if (cp != NULL) {
- if (cp->provider != NULL)
- g_detach(cp);
- g_destroy_consumer(cp);
- }
- if (newpp != NULL)
- g_destroy_provider(newpp);
- if (gp != NULL) {
- if (gp->softc != NULL)
- g_free(gp->softc);
- g_destroy_geom(gp);
- }
+ g_free(sc->sc_provider_name);
+ if (cp->provider != NULL)
+ g_detach(cp);
+ g_destroy_consumer(cp);
+ g_destroy_provider(newpp);
+ g_free(gp->softc);
+ g_destroy_geom(gp);
return (error);
}
diff --git a/sys/geom/multipath/g_multipath.c b/sys/geom/multipath/g_multipath.c
index 6c53f41..6720a87 100644
--- a/sys/geom/multipath/g_multipath.c
+++ b/sys/geom/multipath/g_multipath.c
@@ -293,9 +293,6 @@ g_multipath_create(struct g_class *mp, struct g_multipath_metadata *md)
}
gp = g_new_geomf(mp, md->md_name);
- if (gp == NULL)
- goto fail;
-
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
gp->softc = sc;
gp->start = g_multipath_start;
@@ -305,21 +302,12 @@ g_multipath_create(struct g_class *mp, struct g_multipath_metadata *md)
memcpy(sc->sc_name, md->md_name, sizeof (sc->sc_name));
pp = g_new_providerf(gp, "multipath/%s", md->md_name);
- if (pp == NULL)
- goto fail;
/* limit the provider to not have it stomp on metadata */
pp->mediasize = md->md_size - md->md_sectorsize;
pp->sectorsize = md->md_sectorsize;
sc->pp = pp;
g_error_provider(pp, 0);
return (gp);
-fail:
- if (gp != NULL) {
- if (gp->softc != NULL)
- g_free(gp->softc);
- g_destroy_geom(gp);
- }
- return (NULL);
}
static int
@@ -348,8 +336,6 @@ g_multipath_add_disk(struct g_geom *gp, struct g_provider *pp)
}
nxtcp = LIST_FIRST(&gp->consumer);
cp = g_new_consumer(gp);
- if (cp == NULL)
- return (ENOMEM);
error = g_attach(cp, pp);
if (error != 0) {
printf("GEOM_MULTIPATH: cannot attach %s to %s",
diff --git a/sys/geom/sched/g_sched.c b/sys/geom/sched/g_sched.c
index 031d68d..dd5120f 100644
--- a/sys/geom/sched/g_sched.c
+++ b/sys/geom/sched/g_sched.c
@@ -1004,11 +1004,6 @@ g_sched_create(struct gctl_req *req, struct g_class *mp,
gp = g_new_geomf(mp, name);
dstgp = proxy ? pp->geom : gp; /* where do we link the provider */
- if (gp == NULL) {
- gctl_error(req, "Cannot create geom %s.", name);
- error = ENOMEM;
- goto fail;
- }
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
sc->sc_gsched = gsp;
@@ -1034,23 +1029,10 @@ g_sched_create(struct gctl_req *req, struct g_class *mp,
gp->dumpconf = g_sched_dumpconf;
newpp = g_new_providerf(dstgp, gp->name);
- if (newpp == NULL) {
- gctl_error(req, "Cannot create provider %s.", name);
- error = ENOMEM;
- goto fail;
- }
-
newpp->mediasize = pp->mediasize;
newpp->sectorsize = pp->sectorsize;
cp = g_new_consumer(gp);
- if (cp == NULL) {
- gctl_error(req, "Cannot create consumer for %s.",
- gp->name);
- error = ENOMEM;
- goto fail;
- }
-
error = g_attach(cp, proxy ? newpp : pp);
if (error != 0) {
gctl_error(req, "Cannot attach to provider %s.",
@@ -1076,23 +1058,15 @@ fail:
g_detach(cp);
g_destroy_consumer(cp);
}
-
if (newpp != NULL)
g_destroy_provider(newpp);
-
- if (sc && sc->sc_hash) {
+ if (sc->sc_hash)
g_sched_hash_fini(gp, sc->sc_hash, sc->sc_mask,
gsp, sc->sc_data);
- }
-
- if (sc && sc->sc_data)
+ if (sc->sc_data)
gsp->gs_fini(sc->sc_data);
-
- if (gp != NULL) {
- if (gp->softc != NULL)
- g_free(gp->softc);
- g_destroy_geom(gp);
- }
+ g_free(gp->softc);
+ g_destroy_geom(gp);
return (error);
}
diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c
index a2d9e12..4bf918f 100644
--- a/sys/geom/shsec/g_shsec.c
+++ b/sys/geom/shsec/g_shsec.c
@@ -546,8 +546,6 @@ g_shsec_create(struct g_class *mp, const struct g_shsec_metadata *md)
}
}
gp = g_new_geomf(mp, "%s", md->md_name);
- gp->softc = NULL; /* for a moment */
-
sc = malloc(sizeof(*sc), M_SHSEC, M_WAITOK | M_ZERO);
gp->start = g_shsec_start;
gp->spoiled = g_shsec_orphan;
diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c
index b8faffd..08841b5 100644
--- a/sys/geom/stripe/g_stripe.c
+++ b/sys/geom/stripe/g_stripe.c
@@ -819,8 +819,6 @@ g_stripe_create(struct g_class *mp, const struct g_stripe_metadata *md,
}
}
gp = g_new_geomf(mp, "%s", md->md_name);
- gp->softc = NULL; /* for a moment */
-
sc = malloc(sizeof(*sc), M_STRIPE, M_WAITOK | M_ZERO);
gp->start = g_stripe_start;
gp->spoiled = g_stripe_orphan;
OpenPOWER on IntegriCloud