On Fri, May 21, 2021 at 03:36:48PM -0400, Tony Krowiak wrote: > +static struct kvm_s390_crypto_hook > +*kvm_arch_crypto_find_hook(enum kvm_s390_crypto_hook_type type) > +{ > + struct kvm_s390_crypto_hook *crypto_hook; > + > + list_for_each_entry(crypto_hook, &crypto_hooks, node) { > + if (crypto_hook->type == type) > + return crypto_hook; > + } > + > + return NULL; > +} > + > +int kvm_arch_crypto_register_hook(struct kvm_s390_crypto_hook *hook) > +{ > + struct kvm_s390_crypto_hook *crypto_hook; > + > + mutex_lock(&crypto_hooks_lock); > + crypto_hook = kvm_arch_crypto_find_hook(hook->type); > + if (crypto_hook) { > + if (crypto_hook->owner != hook->owner) > + return -EACCES; > + list_replace(&crypto_hook->node, &hook->node); This is all dead code right? This is only called from a module init function so it can't be called twice. Just always fail if the hook is already used and delete the owner stuff. But this is alot of complicated and unused code to solve a lock ordering problem.. Jason