Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/dm dm: Don't ignore dm_target_alloc() argument



details:   https://anonhg.NetBSD.org/src/rev/fa16897af7ca
branches:  trunk
changeset: 846989:fa16897af7ca
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Fri Dec 06 16:11:59 2019 +0000

description:
dm: Don't ignore dm_target_alloc() argument

dm_target_alloc() is supposed to be copying the name argument to its ->name.
taken-from: DragonFlyBSD

diffstat:

 sys/dev/dm/dm_target.c          |  17 ++++++++++++-----
 sys/dev/dm/dm_target_error.c    |   5 ++---
 sys/dev/dm/dm_target_mirror.c   |   5 ++---
 sys/dev/dm/dm_target_snapshot.c |   6 ++----
 sys/dev/dm/dm_target_stripe.c   |   5 ++---
 sys/dev/dm/dm_target_zero.c     |   5 ++---
 6 files changed, 22 insertions(+), 21 deletions(-)

diffs (190 lines):

diff -r 16fb0da6b6f8 -r fa16897af7ca sys/dev/dm/dm_target.c
--- a/sys/dev/dm/dm_target.c    Fri Dec 06 14:43:29 2019 +0000
+++ b/sys/dev/dm/dm_target.c    Fri Dec 06 16:11:59 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target.c,v 1.22 2019/12/04 15:31:12 tkusumi Exp $      */
+/*        $NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.22 2019/12/04 15:31:12 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -241,7 +241,16 @@
 dm_target_t *
 dm_target_alloc(const char *name)
 {
-       return kmem_zalloc(sizeof(dm_target_t), KM_SLEEP);
+       dm_target_t *dmt;
+
+       dmt = kmem_zalloc(sizeof(dm_target_t), KM_SLEEP);
+       if (dmt == NULL)
+               return NULL;
+
+       if (name)
+               strlcpy(dmt->name, name, sizeof(dmt->name));
+
+       return dmt;
 }
 
 /*
@@ -298,7 +307,6 @@
        dmt->version[0] = 1;
        dmt->version[1] = 0;
        dmt->version[2] = 2;
-       strlcpy(dmt->name, "linear", DM_MAX_TYPE_NAME);
        dmt->init = &dm_target_linear_init;
        dmt->status = &dm_target_linear_status;
        dmt->strategy = &dm_target_linear_strategy;
@@ -313,7 +321,6 @@
        dmt3->version[0] = 1;
        dmt3->version[1] = 0;
        dmt3->version[2] = 3;
-       strlcpy(dmt3->name, "striped", DM_MAX_TYPE_NAME);
        dmt3->init = &dm_target_stripe_init;
        dmt3->status = &dm_target_stripe_status;
        dmt3->strategy = &dm_target_stripe_strategy;
diff -r 16fb0da6b6f8 -r fa16897af7ca sys/dev/dm/dm_target_error.c
--- a/sys/dev/dm/dm_target_error.c      Fri Dec 06 14:43:29 2019 +0000
+++ b/sys/dev/dm/dm_target_error.c      Fri Dec 06 16:11:59 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_error.c,v 1.14 2019/12/05 16:59:43 tkusumi Exp $      */
+/*        $NetBSD: dm_target_error.c,v 1.15 2019/12/06 16:11:59 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.14 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.15 2019/12/06 16:11:59 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper error target.
@@ -81,7 +81,6 @@
                dmt->version[0] = 1;
                dmt->version[1] = 0;
                dmt->version[2] = 0;
-               strlcpy(dmt->name, "error", DM_MAX_TYPE_NAME);
                dmt->init = &dm_target_error_init;
                dmt->status = &dm_target_error_status;
                dmt->strategy = &dm_target_error_strategy;
diff -r 16fb0da6b6f8 -r fa16897af7ca sys/dev/dm/dm_target_mirror.c
--- a/sys/dev/dm/dm_target_mirror.c     Fri Dec 06 14:43:29 2019 +0000
+++ b/sys/dev/dm/dm_target_mirror.c     Fri Dec 06 16:11:59 2019 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_mirror.c,v 1.12 2019/12/05 16:59:43 tkusumi Exp $*/
+/*$NetBSD: dm_target_mirror.c,v 1.13 2019/12/06 16:11:59 tkusumi Exp $*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.12 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.13 2019/12/06 16:11:59 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper mirror target.
@@ -81,7 +81,6 @@
                dmt->version[0] = 1;
                dmt->version[1] = 0;
                dmt->version[2] = 0;
-               strlcpy(dmt->name, "mirror", DM_MAX_TYPE_NAME);
                dmt->init = &dm_target_mirror_init;
                dmt->status = &dm_target_mirror_status;
                dmt->strategy = &dm_target_mirror_strategy;
diff -r 16fb0da6b6f8 -r fa16897af7ca sys/dev/dm/dm_target_snapshot.c
--- a/sys/dev/dm/dm_target_snapshot.c   Fri Dec 06 14:43:29 2019 +0000
+++ b/sys/dev/dm/dm_target_snapshot.c   Fri Dec 06 16:11:59 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_snapshot.c,v 1.23 2019/12/05 16:59:43 tkusumi Exp $      */
+/*        $NetBSD: dm_target_snapshot.c,v 1.24 2019/12/06 16:11:59 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.23 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.24 2019/12/06 16:11:59 tkusumi Exp $");
 
 /*
  * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being
@@ -141,7 +141,6 @@
                dmt->version[0] = 1;
                dmt->version[1] = 0;
                dmt->version[2] = 5;
-               strlcpy(dmt->name, "snapshot", DM_MAX_TYPE_NAME);
                dmt->init = &dm_target_snapshot_init;
                dmt->status = &dm_target_snapshot_status;
                dmt->strategy = &dm_target_snapshot_strategy;
@@ -154,7 +153,6 @@
                dmt1->version[0] = 1;
                dmt1->version[1] = 0;
                dmt1->version[2] = 5;
-               strlcpy(dmt1->name, "snapshot-origin", DM_MAX_TYPE_NAME);
                dmt1->init = &dm_target_snapshot_orig_init;
                dmt1->status = &dm_target_snapshot_orig_status;
                dmt1->strategy = &dm_target_snapshot_orig_strategy;
diff -r 16fb0da6b6f8 -r fa16897af7ca sys/dev/dm/dm_target_stripe.c
--- a/sys/dev/dm/dm_target_stripe.c     Fri Dec 06 14:43:29 2019 +0000
+++ b/sys/dev/dm/dm_target_stripe.c     Fri Dec 06 16:11:59 2019 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_stripe.c,v 1.27 2019/12/05 16:59:43 tkusumi Exp $*/
+/*$NetBSD: dm_target_stripe.c,v 1.28 2019/12/06 16:11:59 tkusumi Exp $*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.27 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.28 2019/12/06 16:11:59 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper stripe target.
@@ -74,7 +74,6 @@
                dmt->version[0] = 1;
                dmt->version[1] = 0;
                dmt->version[2] = 0;
-               strlcpy(dmt->name, "stripe", DM_MAX_TYPE_NAME);
                dmt->init = &dm_target_stripe_init;
                dmt->status = &dm_target_stripe_status;
                dmt->strategy = &dm_target_stripe_strategy;
diff -r 16fb0da6b6f8 -r fa16897af7ca sys/dev/dm/dm_target_zero.c
--- a/sys/dev/dm/dm_target_zero.c       Fri Dec 06 14:43:29 2019 +0000
+++ b/sys/dev/dm/dm_target_zero.c       Fri Dec 06 16:11:59 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_zero.c,v 1.15 2019/12/05 16:59:43 tkusumi Exp $      */
+/*        $NetBSD: dm_target_zero.c,v 1.16 2019/12/06 16:11:59 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.15 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.16 2019/12/06 16:11:59 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper zero target.
@@ -81,7 +81,6 @@
                dmt->version[0] = 1;
                dmt->version[1] = 0;
                dmt->version[2] = 0;
-               strlcpy(dmt->name, "zero", DM_MAX_TYPE_NAME);
                dmt->init = &dm_target_zero_init;
                dmt->status = &dm_target_zero_status;
                dmt->strategy = &dm_target_zero_strategy;



Home | Main Index | Thread Index | Old Index