diff --git a/bsdkm/wolfkmod.c b/bsdkm/wolfkmod.c index 57d982cda9..84e8a01490 100644 --- a/bsdkm/wolfkmod.c +++ b/bsdkm/wolfkmod.c @@ -1020,7 +1020,8 @@ static int wolfkdriv_process(device_t dev, struct cryptop * crp, int hint) csp->csp_mode, csp->csp_cipher_alg, error); #endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */ - return (error); + /* opencrypto(9) contract: return 0 after crypto_done(); error is in crp_etype. */ + return (0); } /* diff --git a/linuxkm/linuxkm_wc_port.h b/linuxkm/linuxkm_wc_port.h index 22255af456..50f7a1f050 100644 --- a/linuxkm/linuxkm_wc_port.h +++ b/linuxkm/linuxkm_wc_port.h @@ -450,6 +450,8 @@ #define memset my_memset static inline void *my_memmove(void *dest, const void *src, size_t n) { + if (n == 0) + return dest; if (! (((uintptr_t)dest | (uintptr_t)src | (uintptr_t)n) & (uintptr_t)(sizeof(uintptr_t) - 1))) { diff --git a/linuxkm/x86_vector_register_glue.c b/linuxkm/x86_vector_register_glue.c index 6879546337..90ae0efcc1 100644 --- a/linuxkm/x86_vector_register_glue.c +++ b/linuxkm/x86_vector_register_glue.c @@ -162,16 +162,22 @@ static struct wc_thread_fpu_count_ent *wc_linuxkm_fpu_state_assoc_unlikely(int c __atomic_store_n(&slot->pid, my_pid, __ATOMIC_RELEASE); return slot; } else { + struct pid *slot_pid_struct; + /* if the slot is already occupied, that can be benign-ish due to a * unwanted migration, or due to a process crashing in kernel mode. * it will require fixup either here, or by the thread that owns the * slot, which will happen when it releases its lock. */ - if (find_get_pid(slot_pid) == NULL) { + slot_pid_struct = find_get_pid(slot_pid); + if (slot_pid_struct == NULL) { if (__atomic_compare_exchange_n(&slot->pid, &slot_pid, my_pid, 0, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE)) { pr_warn("WARNING: wc_linuxkm_fpu_state_assoc_unlikely fixed up orphaned slot on CPU %d owned by dead PID %d.\n", my_cpu, slot_pid); return slot; } + } else { + /* drop the refcount bumped by find_get_pid(). */ + put_pid(slot_pid_struct); } {