Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dm cleanup properly on error.
details: https://anonhg.NetBSD.org/src/rev/ba03d737db1b
branches: trunk
changeset: 331689:ba03d737db1b
user: christos <christos%NetBSD.org@localhost>
date: Tue Aug 19 14:43:28 2014 +0000
description:
cleanup properly on error.
diffstat:
sys/dev/dm/dm_target_stripe.c | 38 ++++++++++++++++++++------------------
1 files changed, 20 insertions(+), 18 deletions(-)
diffs (72 lines):
diff -r 2e3e2bc9635c -r ba03d737db1b sys/dev/dm/dm_target_stripe.c
--- a/sys/dev/dm/dm_target_stripe.c Tue Aug 19 13:44:31 2014 +0000
+++ b/sys/dev/dm/dm_target_stripe.c Tue Aug 19 14:43:28 2014 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_stripe.c,v 1.20 2014/08/18 17:16:42 agc Exp $*/
+/*$NetBSD: dm_target_stripe.c,v 1.21 2014/08/19 14:43:28 christos Exp $*/
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -102,6 +102,23 @@
}
#endif
+static void
+dm_target_stripe_fini(dm_target_stripe_config_t *tsc)
+{
+ dm_target_linear_config_t *tlc;
+
+ if (tsc == NULL)
+ return;
+
+ while ((tlc = TAILQ_FIRST(&tsc->stripe_devs)) != NULL) {
+ TAILQ_REMOVE(&tsc->stripe_devs, tlc, entries);
+ dm_pdev_decr(tlc->pdev);
+ kmem_free(tlc, sizeof(*tlc));
+ }
+
+ kmem_free(tsc, sizeof(*tsc));
+}
+
/*
* Init function called from dm_table_load_ioctl.
* DM_STRIPE_DEV_OFFSET should always hold the index of the first device-offset
@@ -157,8 +174,8 @@
tlc = kmem_alloc(sizeof(*tlc), KM_NOSLEEP);
if ((tlc->pdev = dm_pdev_insert(argv[strpi])) == NULL) {
- kmem_free(tsc, sizeof(*tsc));
kmem_free(tlc, sizeof(*tlc));
+ dm_target_stripe_fini(tsc);
return ENOENT;
}
tlc->offset = atoi(argv[strpi+1]);
@@ -295,27 +312,12 @@
int
dm_target_stripe_destroy(dm_table_entry_t * table_en)
{
- dm_target_stripe_config_t *tsc;
- dm_target_linear_config_t *tlc;
-
- tsc = table_en->target_config;
-
- if (tsc == NULL)
- return 0;
-
- while ((tlc = TAILQ_FIRST(&tsc->stripe_devs)) != NULL) {
- TAILQ_REMOVE(&tsc->stripe_devs, tlc, entries);
- dm_pdev_decr(tlc->pdev);
- kmem_free(tlc, sizeof(*tlc));
- }
+ dm_target_stripe_fini(table_en->target_config);
/* Unbusy target so we can unload it */
dm_target_unbusy(table_en->target);
- kmem_free(tsc, sizeof(*tsc));
-
table_en->target_config = NULL;
-
return 0;
}
/* Doesn't not need to do anything here. */
Home |
Main Index |
Thread Index |
Old Index