diff --git a/sys/compat/linux/common/linux_mod.c b/sys/compat/linux/common/linux_mod.c index b61ad40a26d9..8e2b8c608b09 100644 --- a/sys/compat/linux/common/linux_mod.c +++ b/sys/compat/linux/common/linux_mod.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_mod.c,v 1.9 2017/12/08 15:31:13 kre Exp $ */ +/* $NetBSD: linux_mod.c,v 1.10 2017/12/10 00:43:05 kre Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.9 2017/12/08 15:31:13 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.10 2017/12/10 00:43:05 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_execfmt.h" @@ -136,13 +136,16 @@ linux_sysctl_enable(SYSCTLFN_ARGS) if (error != 0 || newp == NULL) return error; - if (val == 1) { + if (val == *(int *)rnode->sysctl_data) + return 0; + + if (val == 1) error = exec_add(linux_execsw, __arraycount(linux_execsw)); - } else if (val == 0) { + else if (val == 0) error = exec_remove(linux_execsw, __arraycount(linux_execsw)); - } else { + else error = EINVAL; - } + if (error) return error; @@ -160,7 +163,10 @@ compat_linux_modcmd(modcmd_t cmd, void *arg) case MODULE_CMD_INIT: linux_futex_init(); linux_sysctl_init(); - return 0; + error = exec_add(linux_execsw, __arraycount(linux_execsw)); + if (error != 0) + linux_sysctl_fini(); + return error; case MODULE_CMD_FINI: error = exec_remove(linux_execsw, __arraycount(linux_execsw)); diff --git a/sys/compat/linux32/common/linux32_mod.c b/sys/compat/linux32/common/linux32_mod.c index 73cf532dbc78..0f69a15d1c84 100644 --- a/sys/compat/linux32/common/linux32_mod.c +++ b/sys/compat/linux32/common/linux32_mod.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_mod.c,v 1.10 2017/12/08 15:31:13 kre Exp $ */ +/* $NetBSD: linux32_mod.c,v 1.11 2017/12/10 00:43:05 kre Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.10 2017/12/08 15:31:13 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.11 2017/12/10 00:43:05 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_execfmt.h" @@ -95,13 +95,17 @@ linux32_sysctl_enable(SYSCTLFN_ARGS) if (error != 0 || newp == NULL) return error; - if (val == 1) { + if (val == *(int *)rnode->sysctl_data) + return 0; + + if (val == 1) error = exec_add(linux32_execsw, __arraycount(linux32_execsw)); - } else if (val == 0) { - error = exec_remove(linux32_execsw, __arraycount(linux32_execsw)); - } else { + else if (val == 0) + error = + exec_remove(linux32_execsw, __arraycount(linux32_execsw)); + else error = EINVAL; - } + if (error) return error; @@ -118,10 +122,14 @@ compat_linux32_modcmd(modcmd_t cmd, void *arg) switch (cmd) { case MODULE_CMD_INIT: linux32_sysctl_init(); - return 0; + error = exec_add(linux32_execsw, __arraycount(linux32_execsw)); + if (error != 0) + linux32_sysctl_fini(); + return error; case MODULE_CMD_FINI: - error = exec_remove(linux32_execsw, __arraycount(linux32_execsw)); + error = + exec_remove(linux32_execsw, __arraycount(linux32_execsw)); if (error) return error; linux32_sysctl_fini();