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 KASSERT() target handlers
details: https://anonhg.NetBSD.org/src/rev/6a0591c67c4e
branches: trunk
changeset: 967530:6a0591c67c4e
user: tkusumi <tkusumi%NetBSD.org@localhost>
date: Fri Dec 13 16:15:54 2019 +0000
description:
dm: Don't KASSERT() target handlers
Having assertions here causes panic if target is missing anything
as shown in "dm: Add dummy target ->sync()/->secsize() to prevent panic on modload(8)".
Instead just return EINVAL if a handler(s) isn't implemented.
taken-from: DragonFlyBSD
diffstat:
sys/dev/dm/dm_target.c | 44 ++++++++++++++++++++++++++++++++++----------
1 files changed, 34 insertions(+), 10 deletions(-)
diffs (65 lines):
diff -r 43c54c1c4e4f -r 6a0591c67c4e sys/dev/dm/dm_target.c
--- a/sys/dev/dm/dm_target.c Fri Dec 13 15:49:22 2019 +0000
+++ b/sys/dev/dm/dm_target.c Fri Dec 13 16:15:54 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_target.c,v 1.26 2019/12/08 10:35:53 tkusumi Exp $ */
+/* $NetBSD: dm_target.c,v 1.27 2019/12/13 16:15:54 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.26 2019/12/08 10:35:53 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.27 2019/12/13 16:15:54 tkusumi Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -156,14 +156,38 @@
dm_target_t *dmt;
/* Sanity check for any missing function */
- KASSERT(dm_target->init != NULL);
- KASSERT(dm_target->status != NULL);
- KASSERT(dm_target->strategy != NULL);
- KASSERT(dm_target->deps != NULL);
- KASSERT(dm_target->destroy != NULL);
- KASSERT(dm_target->upcall != NULL);
- KASSERT(dm_target->sync != NULL);
- KASSERT(dm_target->secsize != NULL);
+ if (dm_target->init == NULL) {
+ printf("%s missing init\n", dm_target->name);
+ return EINVAL;
+ }
+ if (dm_target->status == NULL) {
+ printf("%s missing status\n", dm_target->name);
+ return EINVAL;
+ }
+ if (dm_target->strategy == NULL) {
+ printf("%s missing strategy\n", dm_target->name);
+ return EINVAL;
+ }
+ if (dm_target->deps == NULL) {
+ printf("%s missing deps\n", dm_target->name);
+ return EINVAL;
+ }
+ if (dm_target->destroy == NULL) {
+ printf("%s missing destroy\n", dm_target->name);
+ return EINVAL;
+ }
+ if (dm_target->upcall == NULL) {
+ printf("%s missing upcall\n", dm_target->name);
+ return EINVAL;
+ }
+ if (dm_target->sync == NULL) {
+ printf("%s missing sync\n", dm_target->name);
+ return EINVAL;
+ }
+ if (dm_target->secsize == NULL) {
+ printf("%s missing secsize\n", dm_target->name);
+ return EINVAL;
+ }
mutex_enter(&dm_target_mutex);
Home |
Main Index |
Thread Index |
Old Index