diff --git a/sys/security/mac_portacl/mac_portacl.c b/sys/security/mac_portacl/mac_portacl.c index aceda6908b1..f54319aca93 100644 --- a/sys/security/mac_portacl/mac_portacl.c +++ b/sys/security/mac_portacl/mac_portacl.c @@ -341,10 +341,12 @@ sysctl_rules(SYSCTL_HANDLER_ARGS) int error; new_string = NULL; - if (req->newptr == NULL) { + if (req->newptr != NULL) { new_string = malloc(MAC_RULE_STRING_LEN, M_PORTACL, M_WAITOK | M_ZERO); + mtx_lock(&rule_mtx); strcpy(new_string, rule_string); + mtx_unlock(&rule_mtx); string = new_string; } else string = rule_string;