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
This commit is contained in:
tkusumi 2019-12-06 16:11:59 +00:00
parent c91905c4be
commit 592bc73589
6 changed files with 22 additions and 21 deletions

View File

@ -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_destroy(void)
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 @@ dm_target_init(void)
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 @@ dm_target_init(void)
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;

View File

@ -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 @@ dm_target_error_modcmd(modcmd_t cmd, void *arg)
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;

View File

@ -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 @@ dm_target_mirror_modcmd(modcmd_t cmd, void *arg)
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;

View File

@ -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 @@ dm_target_snapshot_modcmd(modcmd_t cmd, void *arg)
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 @@ dm_target_snapshot_modcmd(modcmd_t cmd, void *arg)
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;

View File

@ -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 @@ dm_target_stripe_modcmd(modcmd_t cmd, void *arg)
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;

View File

@ -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 @@ dm_target_zero_modcmd(modcmd_t cmd, void *arg)
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;